Project: Identify Customer Segments

By: Ken Norton

In this project, you will apply unsupervised learning techniques to identify segments of the population that form the core customer base for a mail-order sales company in Germany. These segments can then be used to direct marketing campaigns towards audiences that will have the highest expected rate of returns. The data that you will use has been provided by our partners at Bertelsmann Arvato Analytics, and represents a real-life data science task.

This notebook will help you complete this task by providing a framework within which you will perform your analysis steps. In each step of the project, you will see some text describing the subtask that you will perform, followed by one or more code cells for you to complete your work. Feel free to add additional code and markdown cells as you go along so that you can explore everything in precise chunks. The code cells provided in the base template will outline only the major tasks, and will usually not be enough to cover all of the minor tasks that comprise it.

It should be noted that while there will be precise guidelines on how you should handle certain tasks in the project, there will also be places where an exact specification is not provided. There will be times in the project where you will need to make and justify your own decisions on how to treat the data. These are places where there may not be only one way to handle the data. In real-life tasks, there may be many valid ways to approach an analysis task. One of the most important things you can do is clearly document your approach so that other scientists can understand the decisions you've made.

At the end of most sections, there will be a Markdown cell labeled Discussion. In these cells, you will report your findings for the completed section, as well as document the decisions that you made in your approach to each subtask. Your project will be evaluated not just on the code used to complete the tasks outlined, but also your communication about your observations and conclusions at each stage.

In [1]:
# import libraries here; add more as necessary
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
import missingno as msno

from sklearn import preprocessing, decomposition
from sklearn.impute import SimpleImputer
from sklearn.decomposition import PCA
from sklearn.cluster import KMeans
from mpl_toolkits.mplot3d import Axes3D

# magic word for producing visualizations in notebook
%matplotlib inline
%config InlineBackend.figure_format = 'retina'

pd.set_option('display.max_columns', 100)
pd.set_option('display.max_rows', 100)
%load_ext autoreload
%autoreload 2
In [2]:
# Plot styles
plt.style.use('fivethirtyeight')
plt.style.use('seaborn-poster')

Step 0: Load the Data

There are four files associated with this project (not including this one):

  • Udacity_AZDIAS_Subset.csv: Demographics data for the general population of Germany; 891211 persons (rows) x 85 features (columns).
  • Udacity_CUSTOMERS_Subset.csv: Demographics data for customers of a mail-order company; 191652 persons (rows) x 85 features (columns).
  • Data_Dictionary.md: Detailed information file about the features in the provided datasets.
  • AZDIAS_Feature_Summary.csv: Summary of feature attributes for demographics data; 85 features (rows) x 4 columns

Each row of the demographics files represents a single person, but also includes information outside of individuals, including information about their household, building, and neighborhood. You will use this information to cluster the general population into groups with similar demographic properties. Then, you will see how the people in the customers dataset fit into those created clusters. The hope here is that certain clusters are over-represented in the customers data, as compared to the general population; those over-represented clusters will be assumed to be part of the core userbase. This information can then be used for further applications, such as targeting for a marketing campaign.

To start off with, load in the demographics data for the general population into a pandas DataFrame, and do the same for the feature attributes summary. Note for all of the .csv data files in this project: they're semicolon (;) delimited, so you'll need an additional argument in your read_csv() call to read in the data properly. Also, considering the size of the main dataset, it may take some time for it to load completely.

Once the dataset is loaded, it's recommended that you take a little bit of time just browsing the general structure of the dataset and feature summary file. You'll be getting deep into the innards of the cleaning in the first major step of the project, so gaining some general familiarity can help you get your bearings.

In [3]:
# NOTE: the terms of use prevent me from including these files in the repo

# Load in the general demographics data.
azdias = pd.read_csv('Udacity_AZDIAS_Subset.csv', sep=';')

# Load in the feature summary file.
feat_info = pd.read_csv('AZDIAS_Feature_Summary.csv', sep=';')
In [4]:
# Check the structure of the data after it's loaded (e.g. print the number of
# rows and columns, print the first few rows).
print('azdias: ', azdias.shape)
print('feat_info: ', feat_info.shape)
azdias:  (891221, 85)
feat_info:  (85, 4)
In [5]:
azdias.head()
Out[5]:
AGER_TYP ALTERSKATEGORIE_GROB ANREDE_KZ CJT_GESAMTTYP FINANZ_MINIMALIST FINANZ_SPARER FINANZ_VORSORGER FINANZ_ANLEGER FINANZ_UNAUFFAELLIGER FINANZ_HAUSBAUER FINANZTYP GEBURTSJAHR GFK_URLAUBERTYP GREEN_AVANTGARDE HEALTH_TYP LP_LEBENSPHASE_FEIN LP_LEBENSPHASE_GROB LP_FAMILIE_FEIN LP_FAMILIE_GROB LP_STATUS_FEIN LP_STATUS_GROB NATIONALITAET_KZ PRAEGENDE_JUGENDJAHRE RETOURTYP_BK_S SEMIO_SOZ SEMIO_FAM SEMIO_REL SEMIO_MAT SEMIO_VERT SEMIO_LUST SEMIO_ERL SEMIO_KULT SEMIO_RAT SEMIO_KRIT SEMIO_DOM SEMIO_KAEM SEMIO_PFLICHT SEMIO_TRADV SHOPPER_TYP SOHO_KZ TITEL_KZ VERS_TYP ZABEOTYP ALTER_HH ANZ_PERSONEN ANZ_TITEL HH_EINKOMMEN_SCORE KK_KUNDENTYP W_KEIT_KIND_HH WOHNDAUER_2008 ANZ_HAUSHALTE_AKTIV ANZ_HH_TITEL GEBAEUDETYP KONSUMNAEHE MIN_GEBAEUDEJAHR OST_WEST_KZ WOHNLAGE CAMEO_DEUG_2015 CAMEO_DEU_2015 CAMEO_INTL_2015 KBA05_ANTG1 KBA05_ANTG2 KBA05_ANTG3 KBA05_ANTG4 KBA05_BAUMAX KBA05_GBZ BALLRAUM EWDICHTE INNENSTADT GEBAEUDETYP_RASTER KKK MOBI_REGIO ONLINE_AFFINITAET REGIOTYP KBA13_ANZAHL_PKW PLZ8_ANTG1 PLZ8_ANTG2 PLZ8_ANTG3 PLZ8_ANTG4 PLZ8_BAUMAX PLZ8_HHZ PLZ8_GBZ ARBEIT ORTSGR_KLS9 RELAT_AB
0 -1 2 1 2.0 3 4 3 5 5 3 4 0 10.0 0 -1 15.0 4.0 2.0 2.0 1.0 1.0 0 0 5.0 2 6 7 5 1 5 3 3 4 7 6 6 5 3 -1 NaN NaN -1 3 NaN NaN NaN 2.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 1.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
1 -1 1 2 5.0 1 5 2 5 4 5 1 1996 10.0 0 3 21.0 6.0 5.0 3.0 2.0 1.0 1 14 1.0 5 4 4 3 1 2 2 3 6 4 7 4 7 6 3 1.0 0.0 2 5 0.0 2.0 0.0 6.0 NaN 3.0 9.0 11.0 0.0 8.0 1.0 1992.0 W 4.0 8 8A 51 0.0 0.0 0.0 2.0 5.0 1.0 6.0 3.0 8.0 3.0 2.0 1.0 3.0 3.0 963.0 2.0 3.0 2.0 1.0 1.0 5.0 4.0 3.0 5.0 4.0
2 -1 3 2 3.0 1 4 1 2 3 5 1 1979 10.0 1 3 3.0 1.0 1.0 1.0 3.0 2.0 1 15 3.0 4 1 3 3 4 4 6 3 4 7 7 7 3 3 2 0.0 0.0 1 5 17.0 1.0 0.0 4.0 NaN 3.0 9.0 10.0 0.0 1.0 5.0 1992.0 W 2.0 4 4C 24 1.0 3.0 1.0 0.0 0.0 3.0 2.0 4.0 4.0 4.0 2.0 3.0 2.0 2.0 712.0 3.0 3.0 1.0 0.0 1.0 4.0 4.0 3.0 5.0 2.0
3 2 4 2 2.0 4 2 5 2 1 2 6 1957 1.0 0 2 0.0 0.0 0.0 0.0 9.0 4.0 1 8 2.0 5 1 2 1 4 4 7 4 3 4 4 5 4 4 1 0.0 0.0 1 3 13.0 0.0 0.0 1.0 NaN NaN 9.0 1.0 0.0 1.0 4.0 1997.0 W 7.0 2 2A 12 4.0 1.0 0.0 0.0 1.0 4.0 4.0 2.0 6.0 4.0 0.0 4.0 1.0 0.0 596.0 2.0 2.0 2.0 0.0 1.0 3.0 4.0 2.0 3.0 3.0
4 -1 3 1 5.0 4 3 4 1 3 2 5 1963 5.0 0 3 32.0 10.0 10.0 5.0 3.0 2.0 1 8 5.0 6 4 4 2 7 4 4 6 2 3 2 2 4 2 2 0.0 0.0 2 4 20.0 4.0 0.0 5.0 1.0 2.0 9.0 3.0 0.0 1.0 4.0 1992.0 W 3.0 6 6B 43 1.0 4.0 1.0 0.0 0.0 3.0 2.0 5.0 1.0 5.0 3.0 3.0 5.0 5.0 435.0 2.0 4.0 2.0 1.0 2.0 3.0 3.0 4.0 6.0 5.0
In [6]:
feat_info
Out[6]:
attribute information_level type missing_or_unknown
0 AGER_TYP person categorical [-1,0]
1 ALTERSKATEGORIE_GROB person ordinal [-1,0,9]
2 ANREDE_KZ person categorical [-1,0]
3 CJT_GESAMTTYP person categorical [0]
4 FINANZ_MINIMALIST person ordinal [-1]
5 FINANZ_SPARER person ordinal [-1]
6 FINANZ_VORSORGER person ordinal [-1]
7 FINANZ_ANLEGER person ordinal [-1]
8 FINANZ_UNAUFFAELLIGER person ordinal [-1]
9 FINANZ_HAUSBAUER person ordinal [-1]
10 FINANZTYP person categorical [-1]
11 GEBURTSJAHR person numeric [0]
12 GFK_URLAUBERTYP person categorical []
13 GREEN_AVANTGARDE person categorical []
14 HEALTH_TYP person ordinal [-1,0]
15 LP_LEBENSPHASE_FEIN person mixed [0]
16 LP_LEBENSPHASE_GROB person mixed [0]
17 LP_FAMILIE_FEIN person categorical [0]
18 LP_FAMILIE_GROB person categorical [0]
19 LP_STATUS_FEIN person categorical [0]
20 LP_STATUS_GROB person categorical [0]
21 NATIONALITAET_KZ person categorical [-1,0]
22 PRAEGENDE_JUGENDJAHRE person mixed [-1,0]
23 RETOURTYP_BK_S person ordinal [0]
24 SEMIO_SOZ person ordinal [-1,9]
25 SEMIO_FAM person ordinal [-1,9]
26 SEMIO_REL person ordinal [-1,9]
27 SEMIO_MAT person ordinal [-1,9]
28 SEMIO_VERT person ordinal [-1,9]
29 SEMIO_LUST person ordinal [-1,9]
30 SEMIO_ERL person ordinal [-1,9]
31 SEMIO_KULT person ordinal [-1,9]
32 SEMIO_RAT person ordinal [-1,9]
33 SEMIO_KRIT person ordinal [-1,9]
34 SEMIO_DOM person ordinal [-1,9]
35 SEMIO_KAEM person ordinal [-1,9]
36 SEMIO_PFLICHT person ordinal [-1,9]
37 SEMIO_TRADV person ordinal [-1,9]
38 SHOPPER_TYP person categorical [-1]
39 SOHO_KZ person categorical [-1]
40 TITEL_KZ person categorical [-1,0]
41 VERS_TYP person categorical [-1]
42 ZABEOTYP person categorical [-1,9]
43 ALTER_HH household interval [0]
44 ANZ_PERSONEN household numeric []
45 ANZ_TITEL household numeric []
46 HH_EINKOMMEN_SCORE household ordinal [-1,0]
47 KK_KUNDENTYP household categorical [-1]
48 W_KEIT_KIND_HH household ordinal [-1,0]
49 WOHNDAUER_2008 household ordinal [-1,0]
50 ANZ_HAUSHALTE_AKTIV building numeric [0]
51 ANZ_HH_TITEL building numeric []
52 GEBAEUDETYP building categorical [-1,0]
53 KONSUMNAEHE building ordinal []
54 MIN_GEBAEUDEJAHR building numeric [0]
55 OST_WEST_KZ building categorical [-1]
56 WOHNLAGE building mixed [-1]
57 CAMEO_DEUG_2015 microcell_rr4 categorical [-1,X]
58 CAMEO_DEU_2015 microcell_rr4 categorical [XX]
59 CAMEO_INTL_2015 microcell_rr4 mixed [-1,XX]
60 KBA05_ANTG1 microcell_rr3 ordinal [-1]
61 KBA05_ANTG2 microcell_rr3 ordinal [-1]
62 KBA05_ANTG3 microcell_rr3 ordinal [-1]
63 KBA05_ANTG4 microcell_rr3 ordinal [-1]
64 KBA05_BAUMAX microcell_rr3 mixed [-1,0]
65 KBA05_GBZ microcell_rr3 ordinal [-1,0]
66 BALLRAUM postcode ordinal [-1]
67 EWDICHTE postcode ordinal [-1]
68 INNENSTADT postcode ordinal [-1]
69 GEBAEUDETYP_RASTER region_rr1 ordinal []
70 KKK region_rr1 ordinal [-1,0]
71 MOBI_REGIO region_rr1 ordinal []
72 ONLINE_AFFINITAET region_rr1 ordinal []
73 REGIOTYP region_rr1 ordinal [-1,0]
74 KBA13_ANZAHL_PKW macrocell_plz8 numeric []
75 PLZ8_ANTG1 macrocell_plz8 ordinal [-1]
76 PLZ8_ANTG2 macrocell_plz8 ordinal [-1]
77 PLZ8_ANTG3 macrocell_plz8 ordinal [-1]
78 PLZ8_ANTG4 macrocell_plz8 ordinal [-1]
79 PLZ8_BAUMAX macrocell_plz8 mixed [-1,0]
80 PLZ8_HHZ macrocell_plz8 ordinal [-1]
81 PLZ8_GBZ macrocell_plz8 ordinal [-1]
82 ARBEIT community ordinal [-1,9]
83 ORTSGR_KLS9 community ordinal [-1,0]
84 RELAT_AB community ordinal [-1,9]
In [7]:
feat_info.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 85 entries, 0 to 84
Data columns (total 4 columns):
attribute             85 non-null object
information_level     85 non-null object
type                  85 non-null object
missing_or_unknown    85 non-null object
dtypes: object(4)
memory usage: 2.7+ KB

Step 1: Preprocessing

Step 1.1: Assess Missing Data

The feature summary file contains a summary of properties for each demographics data column. You will use this file to help you make cleaning decisions during this stage of the project. First of all, you should assess the demographics data in terms of missing data. Pay attention to the following points as you perform your analysis, and take notes on what you observe. Make sure that you fill in the Discussion cell with your findings and decisions at the end of each step that has one!

Step 1.1.1: Convert Missing Value Codes to NaNs

The fourth column of the feature attributes summary (loaded in above as feat_info) documents the codes from the data dictionary that indicate missing or unknown data. While the file encodes this as a list (e.g. [-1,0]), this will get read in as a string object. You'll need to do a little bit of parsing to make use of it to identify and clean the data. Convert data that matches a 'missing' or 'unknown' value code into a numpy NaN value. You might want to see how much data takes on a 'missing' or 'unknown' code, and how much data is naturally missing, as a point of interest.

As one more reminder, you are encouraged to add additional cells to break up your analysis into manageable chunks.

In [8]:
df_clean = azdias.copy()
In [9]:
df_clean.dtypes
Out[9]:
AGER_TYP                   int64
ALTERSKATEGORIE_GROB       int64
ANREDE_KZ                  int64
CJT_GESAMTTYP            float64
FINANZ_MINIMALIST          int64
FINANZ_SPARER              int64
FINANZ_VORSORGER           int64
FINANZ_ANLEGER             int64
FINANZ_UNAUFFAELLIGER      int64
FINANZ_HAUSBAUER           int64
FINANZTYP                  int64
GEBURTSJAHR                int64
GFK_URLAUBERTYP          float64
GREEN_AVANTGARDE           int64
HEALTH_TYP                 int64
LP_LEBENSPHASE_FEIN      float64
LP_LEBENSPHASE_GROB      float64
LP_FAMILIE_FEIN          float64
LP_FAMILIE_GROB          float64
LP_STATUS_FEIN           float64
LP_STATUS_GROB           float64
NATIONALITAET_KZ           int64
PRAEGENDE_JUGENDJAHRE      int64
RETOURTYP_BK_S           float64
SEMIO_SOZ                  int64
SEMIO_FAM                  int64
SEMIO_REL                  int64
SEMIO_MAT                  int64
SEMIO_VERT                 int64
SEMIO_LUST                 int64
SEMIO_ERL                  int64
SEMIO_KULT                 int64
SEMIO_RAT                  int64
SEMIO_KRIT                 int64
SEMIO_DOM                  int64
SEMIO_KAEM                 int64
SEMIO_PFLICHT              int64
SEMIO_TRADV                int64
SHOPPER_TYP                int64
SOHO_KZ                  float64
TITEL_KZ                 float64
VERS_TYP                   int64
ZABEOTYP                   int64
ALTER_HH                 float64
ANZ_PERSONEN             float64
ANZ_TITEL                float64
HH_EINKOMMEN_SCORE       float64
KK_KUNDENTYP             float64
W_KEIT_KIND_HH           float64
WOHNDAUER_2008           float64
ANZ_HAUSHALTE_AKTIV      float64
ANZ_HH_TITEL             float64
GEBAEUDETYP              float64
KONSUMNAEHE              float64
MIN_GEBAEUDEJAHR         float64
OST_WEST_KZ               object
WOHNLAGE                 float64
CAMEO_DEUG_2015           object
CAMEO_DEU_2015            object
CAMEO_INTL_2015           object
KBA05_ANTG1              float64
KBA05_ANTG2              float64
KBA05_ANTG3              float64
KBA05_ANTG4              float64
KBA05_BAUMAX             float64
KBA05_GBZ                float64
BALLRAUM                 float64
EWDICHTE                 float64
INNENSTADT               float64
GEBAEUDETYP_RASTER       float64
KKK                      float64
MOBI_REGIO               float64
ONLINE_AFFINITAET        float64
REGIOTYP                 float64
KBA13_ANZAHL_PKW         float64
PLZ8_ANTG1               float64
PLZ8_ANTG2               float64
PLZ8_ANTG3               float64
PLZ8_ANTG4               float64
PLZ8_BAUMAX              float64
PLZ8_HHZ                 float64
PLZ8_GBZ                 float64
ARBEIT                   float64
ORTSGR_KLS9              float64
RELAT_AB                 float64
dtype: object
In [10]:
feat_info[feat_info.missing_or_unknown.str.contains('X')]
Out[10]:
attribute information_level type missing_or_unknown
57 CAMEO_DEUG_2015 microcell_rr4 categorical [-1,X]
58 CAMEO_DEU_2015 microcell_rr4 categorical [XX]
59 CAMEO_INTL_2015 microcell_rr4 mixed [-1,XX]
In [11]:
# Test one of the columns, we see string values here
df_clean.CAMEO_DEUG_2015.unique()
Out[11]:
array([nan, '8', '4', '2', '6', '1', '9', '5', '7', '3', 'X'],
      dtype=object)
In [12]:
# Identify missing or unknown data values and convert them to NaNs.
df_clean.loc[df_clean['CAMEO_DEUG_2015'] == 'X'] = np.nan
df_clean.loc[df_clean['CAMEO_DEU_2015'] == 'XX'] = np.nan
df_clean.loc[df_clean['CAMEO_INTL_2015'] == 'XX'] = np.nan

# Now convert two of the columns to numeric since strings are gone, keep _DEU_ as string
df_clean['CAMEO_DEUG_2015'] = pd.to_numeric(df_clean['CAMEO_DEUG_2015'], errors='coerce')
df_clean['CAMEO_INTL_2015'] = pd.to_numeric(df_clean['CAMEO_INTL_2015'], errors='coerce')
In [13]:
# Let's retest that column, expect to see integers!
df_clean.CAMEO_DEUG_2015.unique()
Out[13]:
array([nan,  8.,  4.,  2.,  6.,  1.,  9.,  5.,  7.,  3.])
In [14]:
# Iterate over the feat_info df - this is not the most efficient
# way to do it, and I'd like to try to handle the string values
# in one single for-loop as an improvement
for index, row in feat_info.iterrows():
    attr = row['attribute']
    # Strip out the brackets and separate on comma
    values = row['missing_or_unknown'].replace('[', '').replace(']',
                                                                '').split(',')
    for val in values:
        # We still have strings in here (X / XX) so ignore them
        if val not in ['', 'X', 'XX']:
            val = int(val)
            df_clean.loc[df_clean[attr] == val, attr] = np.nan

Step 1.1.2: Assess Missing Data in Each Column

How much missing data is present in each column? There are a few columns that are outliers in terms of the proportion of values that are missing. You will want to use matplotlib's hist() function to visualize the distribution of missing value counts to find these columns. Identify and document these columns. While some of these columns might have justifications for keeping or re-encoding the data, for this project you should just remove them from the dataframe. (Feel free to make remarks about these outlier columns in the discussion, however!)

For the remaining features, are there any patterns in which columns have, or share, missing data?

In [15]:
# Perform an assessment of how much missing data there is in each column of the
# dataset.
# Thanks StackOverflow: https://stackoverflow.com/a/51071037
percent_missing = df_clean.isnull().sum() * 100 / len(df_clean)
missing_values = pd.DataFrame({
    'column_name': df_clean.columns,
    'percent_missing': percent_missing
})
In [16]:
# Investigate patterns in the amount of missing data in each column.

plt.hist(missing_values['percent_missing'], bins=20)
plt.show()
In [17]:
missing_values.sort_values(by='percent_missing', ascending=False).head(25)
Out[17]:
column_name percent_missing
TITEL_KZ TITEL_KZ 99.757636
AGER_TYP AGER_TYP 76.963739
KK_KUNDENTYP KK_KUNDENTYP 65.620312
KBA05_BAUMAX KBA05_BAUMAX 53.485387
GEBURTSJAHR GEBURTSJAHR 44.049007
ALTER_HH ALTER_HH 34.842312
KKK KKK 17.769218
REGIOTYP REGIOTYP 17.769218
W_KEIT_KIND_HH W_KEIT_KIND_HH 16.640990
KBA05_ANTG1 KBA05_ANTG1 14.992802
KBA05_ANTG2 KBA05_ANTG2 14.992802
KBA05_ANTG3 KBA05_ANTG3 14.992802
KBA05_ANTG4 KBA05_ANTG4 14.992802
KBA05_GBZ KBA05_GBZ 14.992802
MOBI_REGIO MOBI_REGIO 14.992802
PLZ8_ANTG3 PLZ8_ANTG3 13.109655
PLZ8_ANTG2 PLZ8_ANTG2 13.109655
PLZ8_GBZ PLZ8_GBZ 13.109655
PLZ8_HHZ PLZ8_HHZ 13.109655
PLZ8_ANTG1 PLZ8_ANTG1 13.109655
PLZ8_BAUMAX PLZ8_BAUMAX 13.109655
PLZ8_ANTG4 PLZ8_ANTG4 13.109655
VERS_TYP VERS_TYP 12.515975
HEALTH_TYP HEALTH_TYP 12.515975
SHOPPER_TYP SHOPPER_TYP 12.515975

Several of our columns have >50% missing values. Looking at them, they are:

  • TITEL_KZ Academic title flag
  • AGER_TYP Best-ager typology
  • KK_KUNDENTYP Consumer pattern over past 12 months
  • KBA05_BAUMAX Most common building type within the microcell
  • GEBURTSJAHR Year of birth

Let's drop all of these columns.

In [18]:
# Remove the outlier columns from the dataset. (You'll perform other data
# engineering tasks such as re-encoding and imputation later.)

df_clean = df_clean.drop(
    columns=['TITEL_KZ', 'AGER_TYP', 'KK_KUNDENTYP', 'KBA05_BAUMAX', 'GEBURTSJAHR'])

Discussion 1.1.2: Assess Missing Data in Each Column

I decided to remove any column that didn't have at least 50% coverage. The columns I removed were:

  • TITEL_KZ Academic title flag
  • AGER_TYP Best-ager typology
  • KK_KUNDENTYP Consumer pattern over past 12 months
  • KBA05_BAUMAX Most common building type within the microcell
  • GEBURTSJAHR Year of birth

Some of them seem like they would have been useful (such as consumer pattern and year of birth), but potentially the present values could be biased. For example, it's possible older respondents reported their year of birth but younger respondents did not. With >50% missing values, it's best to just remove the data from analysis.

Step 1.1.3: Assess Missing Data in Each Row

Now, you'll perform a similar assessment for the rows of the dataset. How much data is missing in each row? As with the columns, you should see some groups of points that have a very different numbers of missing values. Divide the data into two subsets: one for data points that are above some threshold for missing values, and a second subset for points below that threshold.

In order to know what to do with the outlier rows, we should see if the distribution of data values on columns that are not missing data (or are missing very little data) are similar or different between the two groups. Select at least five of these columns and compare the distribution of values.

  • You can use seaborn's countplot() function to create a bar chart of code frequencies and matplotlib's subplot() function to put bar charts for the two subplots side by side.
  • To reduce repeated code, you might want to write a function that can perform this comparison, taking as one of its arguments a column to be compared.

Depending on what you observe in your comparison, this will have implications on how you approach your conclusions later in the analysis. If the distributions of non-missing features look similar between the data with many missing values and the data with few or no missing values, then we could argue that simply dropping those points from the analysis won't present a major issue. On the other hand, if the data with many missing values looks very different from the data with few or no missing values, then we should make a note on those data as special. We'll revisit these data later on. Either way, you should continue your analysis for now using just the subset of the data with few or no missing values.

In [19]:
# How much data is missing in each row of the dataset?
msno.matrix(df_clean.sample(100), figsize=(20, 15), labels=True, fontsize=10)
plt.show()
In [20]:
msno.bar(df_clean, figsize=(20, 8), fontsize=12)
plt.show()

From my visual evaluation I can see that the rows with missing data tend to have a pattern where they're missing all of the household and building-level features. Most of these rows seem to be missing HEALTH_TYP. The easiest way to do this is to test if HEALTH_TYP is null, that column will be missing in all of the cases we're testing for.

In [21]:
# Create a new dataframe that contains only the "complete" rows
df_subset = df_clean.query('HEALTH_TYP != "NaN"')

# Create another dataframe that contains only the "incomplete" rows
df_incomplete = df_clean.query('HEALTH_TYP == "NaN"')
In [22]:
# Test our missing distribution again to make sure the rows look mostly complete
msno.bar(df_subset, figsize=(20, 8), fontsize=12)
plt.show()
In [23]:
# Compare the distribution of values for at least five columns where there are
# no or few missing values, between the two subsets.
df1 = pd.DataFrame(df_subset,
                   columns=[
                       'LP_LEBENSPHASE_FEIN', 'PRAEGENDE_JUGENDJAHRE',
                       'SEMIO_VERT', 'ALTERSKATEGORIE_GROB', 'LP_STATUS_GROB',
                       'ONLINE_AFFINITAET'
                   ]).assign(group='complete')
df2 = pd.DataFrame(df_incomplete,
                   columns=[
                       'LP_LEBENSPHASE_FEIN', 'PRAEGENDE_JUGENDJAHRE',
                       'SEMIO_VERT', 'ALTERSKATEGORIE_GROB', 'LP_STATUS_GROB',
                       'ONLINE_AFFINITAET'
                   ]).assign(group='missing')

cdf = pd.concat([df1, df2])
mdf = pd.melt(cdf, id_vars=['group'], var_name=['column'])
ax = sns.boxplot(x="group", y="value", hue="column", data=mdf)
plt.show()

There doesn't appear to be a significant difference between the two subsets on the columns I investigated. For that reason I'm going to proceed with dropping all rows that are missing HEALTH_TYP.

Step 1.2: Select and Re-Encode Features

Checking for missing data isn't the only way in which you can prepare a dataset for analysis. Since the unsupervised learning techniques to be used will only work on data that is encoded numerically, you need to make a few encoding changes or additional assumptions to be able to make progress. In addition, while almost all of the values in the dataset are encoded using numbers, not all of them represent numeric values. Check the third column of the feature summary (feat_info) for a summary of types of measurement.

  • For numeric and interval data, these features can be kept without changes.
  • Most of the variables in the dataset are ordinal in nature. While ordinal values may technically be non-linear in spacing, make the simplifying assumption that the ordinal variables can be treated as being interval in nature (that is, kept without any changes).
  • Special handling may be necessary for the remaining two variable types: categorical, and 'mixed'.

In the first two parts of this sub-step, you will perform an investigation of the categorical and mixed-type features and make a decision on each of them, whether you will keep, drop, or re-encode each. Then, in the last part, you will create a new data frame with only the selected and engineered columns.

Data wrangling is often the trickiest part of the data analysis process, and there's a lot of it to be done here. But stick with it: once you're done with this step, you'll be ready to get to the machine learning parts of the project!

In [24]:
# How many features are there of each data type?
feat_info.groupby('type')['attribute'].value_counts()
Out[24]:
type         attribute            
categorical  AGER_TYP                 1
             ANREDE_KZ                1
             CAMEO_DEUG_2015          1
             CAMEO_DEU_2015           1
             CJT_GESAMTTYP            1
             FINANZTYP                1
             GEBAEUDETYP              1
             GFK_URLAUBERTYP          1
             GREEN_AVANTGARDE         1
             KK_KUNDENTYP             1
             LP_FAMILIE_FEIN          1
             LP_FAMILIE_GROB          1
             LP_STATUS_FEIN           1
             LP_STATUS_GROB           1
             NATIONALITAET_KZ         1
             OST_WEST_KZ              1
             SHOPPER_TYP              1
             SOHO_KZ                  1
             TITEL_KZ                 1
             VERS_TYP                 1
             ZABEOTYP                 1
interval     ALTER_HH                 1
mixed        CAMEO_INTL_2015          1
             KBA05_BAUMAX             1
             LP_LEBENSPHASE_FEIN      1
             LP_LEBENSPHASE_GROB      1
             PLZ8_BAUMAX              1
             PRAEGENDE_JUGENDJAHRE    1
             WOHNLAGE                 1
numeric      ANZ_HAUSHALTE_AKTIV      1
             ANZ_HH_TITEL             1
             ANZ_PERSONEN             1
             ANZ_TITEL                1
             GEBURTSJAHR              1
             KBA13_ANZAHL_PKW         1
             MIN_GEBAEUDEJAHR         1
ordinal      ALTERSKATEGORIE_GROB     1
             ARBEIT                   1
             BALLRAUM                 1
             EWDICHTE                 1
             FINANZ_ANLEGER           1
             FINANZ_HAUSBAUER         1
             FINANZ_MINIMALIST        1
             FINANZ_SPARER            1
             FINANZ_UNAUFFAELLIGER    1
             FINANZ_VORSORGER         1
             GEBAEUDETYP_RASTER       1
             HEALTH_TYP               1
             HH_EINKOMMEN_SCORE       1
             INNENSTADT               1
             KBA05_ANTG1              1
             KBA05_ANTG2              1
             KBA05_ANTG3              1
             KBA05_ANTG4              1
             KBA05_GBZ                1
             KKK                      1
             KONSUMNAEHE              1
             MOBI_REGIO               1
             ONLINE_AFFINITAET        1
             ORTSGR_KLS9              1
             PLZ8_ANTG1               1
             PLZ8_ANTG2               1
             PLZ8_ANTG3               1
             PLZ8_ANTG4               1
             PLZ8_GBZ                 1
             PLZ8_HHZ                 1
             REGIOTYP                 1
             RELAT_AB                 1
             RETOURTYP_BK_S           1
             SEMIO_DOM                1
             SEMIO_ERL                1
             SEMIO_FAM                1
             SEMIO_KAEM               1
             SEMIO_KRIT               1
             SEMIO_KULT               1
             SEMIO_LUST               1
             SEMIO_MAT                1
             SEMIO_PFLICHT            1
             SEMIO_RAT                1
             SEMIO_REL                1
             SEMIO_SOZ                1
             SEMIO_TRADV              1
             SEMIO_VERT               1
             WOHNDAUER_2008           1
             W_KEIT_KIND_HH           1
Name: attribute, dtype: int64
In [25]:
feat_info.query('type == "categorical"')['attribute'].to_list()
Out[25]:
['AGER_TYP',
 'ANREDE_KZ',
 'CJT_GESAMTTYP',
 'FINANZTYP',
 'GFK_URLAUBERTYP',
 'GREEN_AVANTGARDE',
 'LP_FAMILIE_FEIN',
 'LP_FAMILIE_GROB',
 'LP_STATUS_FEIN',
 'LP_STATUS_GROB',
 'NATIONALITAET_KZ',
 'SHOPPER_TYP',
 'SOHO_KZ',
 'TITEL_KZ',
 'VERS_TYP',
 'ZABEOTYP',
 'KK_KUNDENTYP',
 'GEBAEUDETYP',
 'OST_WEST_KZ',
 'CAMEO_DEUG_2015',
 'CAMEO_DEU_2015']

Step 1.2.1: Re-Encode Categorical Features

For categorical data, you would ordinarily need to encode the levels as dummy variables. Depending on the number of categories, perform one of the following:

  • For binary (two-level) categoricals that take numeric values, you can keep them without needing to do anything.
  • There is one binary variable that takes on non-numeric values. For this one, you need to re-encode the values as numbers or create a dummy variable.
  • For multi-level categoricals (three or more values), you can choose to encode the values using multiple dummy variables (e.g. via OneHotEncoder), or (to keep things straightforward) just drop them from the analysis. As always, document your choices in the Discussion section.
In [26]:
# Assess categorical variables: which are binary, which are multi-level, and
# which one needs to be re-encoded?
In [27]:
# Re-encode categorical variable(s) to be kept in the analysis.

# One-hot encode the multi-level categoricals and string columns
df_subset = pd.get_dummies(
    df_subset,
    columns=[
        'ANREDE_KZ', 'CJT_GESAMTTYP', 'FINANZTYP',
        'GFK_URLAUBERTYP', 'GREEN_AVANTGARDE', 'LP_FAMILIE_FEIN',
        'LP_FAMILIE_GROB', 'LP_STATUS_FEIN', 'LP_STATUS_GROB',
        'NATIONALITAET_KZ', 'SHOPPER_TYP', 'SOHO_KZ', 'VERS_TYP',
        'ZABEOTYP', 'GEBAEUDETYP', 'OST_WEST_KZ',
        'CAMEO_DEUG_2015', 'CAMEO_DEU_2015'
    ],
    prefix_sep='_')
In [28]:
df_subset.head()
Out[28]:
ALTERSKATEGORIE_GROB FINANZ_MINIMALIST FINANZ_SPARER FINANZ_VORSORGER FINANZ_ANLEGER FINANZ_UNAUFFAELLIGER FINANZ_HAUSBAUER HEALTH_TYP LP_LEBENSPHASE_FEIN LP_LEBENSPHASE_GROB PRAEGENDE_JUGENDJAHRE RETOURTYP_BK_S SEMIO_SOZ SEMIO_FAM SEMIO_REL SEMIO_MAT SEMIO_VERT SEMIO_LUST SEMIO_ERL SEMIO_KULT SEMIO_RAT SEMIO_KRIT SEMIO_DOM SEMIO_KAEM SEMIO_PFLICHT SEMIO_TRADV ALTER_HH ANZ_PERSONEN ANZ_TITEL HH_EINKOMMEN_SCORE W_KEIT_KIND_HH WOHNDAUER_2008 ANZ_HAUSHALTE_AKTIV ANZ_HH_TITEL KONSUMNAEHE MIN_GEBAEUDEJAHR WOHNLAGE CAMEO_INTL_2015 KBA05_ANTG1 KBA05_ANTG2 KBA05_ANTG3 KBA05_ANTG4 KBA05_GBZ BALLRAUM EWDICHTE INNENSTADT GEBAEUDETYP_RASTER KKK MOBI_REGIO ONLINE_AFFINITAET ... CAMEO_DEUG_2015_4.0 CAMEO_DEUG_2015_5.0 CAMEO_DEUG_2015_6.0 CAMEO_DEUG_2015_7.0 CAMEO_DEUG_2015_8.0 CAMEO_DEUG_2015_9.0 CAMEO_DEU_2015_1A CAMEO_DEU_2015_1B CAMEO_DEU_2015_1C CAMEO_DEU_2015_1D CAMEO_DEU_2015_1E CAMEO_DEU_2015_2A CAMEO_DEU_2015_2B CAMEO_DEU_2015_2C CAMEO_DEU_2015_2D CAMEO_DEU_2015_3A CAMEO_DEU_2015_3B CAMEO_DEU_2015_3C CAMEO_DEU_2015_3D CAMEO_DEU_2015_4A CAMEO_DEU_2015_4B CAMEO_DEU_2015_4C CAMEO_DEU_2015_4D CAMEO_DEU_2015_4E CAMEO_DEU_2015_5A CAMEO_DEU_2015_5B CAMEO_DEU_2015_5C CAMEO_DEU_2015_5D CAMEO_DEU_2015_5E CAMEO_DEU_2015_5F CAMEO_DEU_2015_6A CAMEO_DEU_2015_6B CAMEO_DEU_2015_6C CAMEO_DEU_2015_6D CAMEO_DEU_2015_6E CAMEO_DEU_2015_6F CAMEO_DEU_2015_7A CAMEO_DEU_2015_7B CAMEO_DEU_2015_7C CAMEO_DEU_2015_7D CAMEO_DEU_2015_7E CAMEO_DEU_2015_8A CAMEO_DEU_2015_8B CAMEO_DEU_2015_8C CAMEO_DEU_2015_8D CAMEO_DEU_2015_9A CAMEO_DEU_2015_9B CAMEO_DEU_2015_9C CAMEO_DEU_2015_9D CAMEO_DEU_2015_9E
1 1.0 1.0 5.0 2.0 5.0 4.0 5.0 3.0 21.0 6.0 14.0 1.0 5.0 4.0 4.0 3.0 1.0 2.0 2.0 3.0 6.0 4.0 7.0 4.0 7.0 6.0 NaN 2.0 0.0 6.0 3.0 9.0 11.0 0.0 1.0 1992.0 4.0 51.0 0.0 0.0 0.0 2.0 1.0 6.0 3.0 8.0 3.0 2.0 1.0 3.0 ... 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
2 3.0 1.0 4.0 1.0 2.0 3.0 5.0 3.0 3.0 1.0 15.0 3.0 4.0 1.0 3.0 3.0 4.0 4.0 6.0 3.0 4.0 7.0 7.0 7.0 3.0 3.0 17.0 1.0 0.0 4.0 3.0 9.0 10.0 0.0 5.0 1992.0 2.0 24.0 1.0 3.0 1.0 0.0 3.0 2.0 4.0 4.0 4.0 2.0 3.0 2.0 ... 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3 4.0 4.0 2.0 5.0 2.0 1.0 2.0 2.0 NaN NaN 8.0 2.0 5.0 1.0 2.0 1.0 4.0 4.0 7.0 4.0 3.0 4.0 4.0 5.0 4.0 4.0 13.0 0.0 0.0 1.0 NaN 9.0 1.0 0.0 4.0 1997.0 7.0 12.0 4.0 1.0 0.0 0.0 4.0 4.0 2.0 6.0 4.0 NaN 4.0 1.0 ... 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4 3.0 4.0 3.0 4.0 1.0 3.0 2.0 3.0 32.0 10.0 8.0 5.0 6.0 4.0 4.0 2.0 7.0 4.0 4.0 6.0 2.0 3.0 2.0 2.0 4.0 2.0 20.0 4.0 0.0 5.0 2.0 9.0 3.0 0.0 4.0 1992.0 3.0 43.0 1.0 4.0 1.0 0.0 3.0 2.0 5.0 1.0 5.0 3.0 3.0 5.0 ... 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5 1.0 3.0 1.0 5.0 2.0 2.0 5.0 3.0 8.0 2.0 3.0 3.0 2.0 4.0 7.0 4.0 2.0 2.0 2.0 5.0 7.0 4.0 4.0 4.0 7.0 6.0 10.0 1.0 0.0 5.0 6.0 9.0 5.0 0.0 5.0 1992.0 7.0 54.0 2.0 2.0 0.0 0.0 4.0 6.0 2.0 7.0 4.0 4.0 4.0 1.0 ... 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0

5 rows × 200 columns

In [29]:
df_subset.shape
Out[29]:
(779676, 200)

Discussion 1.2.1: Re-Encode Categorical Features

I took all of the categorical columns and one-hot encoded them. I considered transforming the one binary variable OST_WEST_KZ but realized it would transform quite nicely into two one-hot encoded variables. I decided not to drop any columns at this stage.

Step 1.2.2: Engineer Mixed-Type Features

There are a handful of features that are marked as "mixed" in the feature summary that require special treatment in order to be included in the analysis. There are two in particular that deserve attention; the handling of the rest are up to your own choices:

  • "PRAEGENDE_JUGENDJAHRE" combines information on three dimensions: generation by decade, movement (mainstream vs. avantgarde), and nation (east vs. west). While there aren't enough levels to disentangle east from west, you should create two new variables to capture the other two dimensions: an interval-type variable for decade, and a binary variable for movement.
  • "CAMEO_INTL_2015" combines information on two axes: wealth and life stage. Break up the two-digit codes by their 'tens'-place and 'ones'-place digits into two new ordinal variables (which, for the purposes of this project, is equivalent to just treating them as their raw numeric values).
  • If you decide to keep or engineer new features around the other mixed-type features, make sure you note your steps in the Discussion section.

Be sure to check Data_Dictionary.md for the details needed to finish these tasks.

1.18. PRAEGENDE_JUGENDJAHRE
Dominating movement of person's youth (avantgarde vs. mainstream; east vs. west)

-1: unknown
0: unknown
1: 40s - war years (Mainstream, E+W)
2: 40s - reconstruction years (Avantgarde, E+W)
3: 50s - economic miracle (Mainstream, E+W)
4: 50s - milk bar / Individualisation (Avantgarde, E+W)
5: 60s - economic miracle (Mainstream, E+W)
6: 60s - generation 68 / student protestors (Avantgarde, W)
7: 60s - opponents to the building of the Wall (Avantgarde, E)
8: 70s - family orientation (Mainstream, E+W)
9: 70s - peace movement (Avantgarde, E+W)
10: 80s - Generation Golf (Mainstream, W)
11: 80s - ecological awareness (Avantgarde, W)
12: 80s - FDJ / communist party youth organisation (Mainstream, E)
13: 80s - Swords into ploughshares (Avantgarde, E)
14: 90s - digital media kids (Mainstream, E+W)
15: 90s - ecological awareness (Avantgarde, E+W)
In [30]:
# Investigate "PRAEGENDE_JUGENDJAHRE" and engineer two new variables

# Create new one-hot encoded columns
df_subset['DECADE_40s'] = df_subset['PRAEGENDE_JUGENDJAHRE'].apply(
    lambda x: 1 if x >= 1 and x <= 2 else 0)
df_subset['DECADE_50s'] = df_subset['PRAEGENDE_JUGENDJAHRE'].apply(
    lambda x: 1 if x >= 3 and x <= 4 else 0)
df_subset['DECADE_60s'] = df_subset['PRAEGENDE_JUGENDJAHRE'].apply(
    lambda x: 1 if x >= 5 and x <= 7 else 0)
df_subset['DECADE_70s'] = df_subset['PRAEGENDE_JUGENDJAHRE'].apply(
    lambda x: 1 if x >= 8 and x <= 9 else 0)
df_subset['DECADE_80s'] = df_subset['PRAEGENDE_JUGENDJAHRE'].apply(
    lambda x: 1 if x >= 10 and x <= 13 else 0)
df_subset['DECADE_90s'] = df_subset['PRAEGENDE_JUGENDJAHRE'].apply(
    lambda x: 1 if x >= 14 and x <= 15 else 0)
In [31]:
# Create new one-hot encoded movement columns

df_subset['MOVEMENT_MAINSTREAM'] = df_subset['PRAEGENDE_JUGENDJAHRE'].apply(
    lambda x: 1 if x in [1, 3, 5, 8, 10, 12, 14] else 0)
df_subset['MOVEMENT_AVANTGARDE'] = df_subset['PRAEGENDE_JUGENDJAHRE'].apply(
    lambda x: 1 if x in [2, 4, 6, 7, 9, 11, 13, 15] else 0)
In [32]:
# Drop the original column
df_subset = df_subset.drop(columns=['PRAEGENDE_JUGENDJAHRE'])
In [33]:
# Test a sample of rows
df_subset.sample(10)
Out[33]:
ALTERSKATEGORIE_GROB FINANZ_MINIMALIST FINANZ_SPARER FINANZ_VORSORGER FINANZ_ANLEGER FINANZ_UNAUFFAELLIGER FINANZ_HAUSBAUER HEALTH_TYP LP_LEBENSPHASE_FEIN LP_LEBENSPHASE_GROB RETOURTYP_BK_S SEMIO_SOZ SEMIO_FAM SEMIO_REL SEMIO_MAT SEMIO_VERT SEMIO_LUST SEMIO_ERL SEMIO_KULT SEMIO_RAT SEMIO_KRIT SEMIO_DOM SEMIO_KAEM SEMIO_PFLICHT SEMIO_TRADV ALTER_HH ANZ_PERSONEN ANZ_TITEL HH_EINKOMMEN_SCORE W_KEIT_KIND_HH WOHNDAUER_2008 ANZ_HAUSHALTE_AKTIV ANZ_HH_TITEL KONSUMNAEHE MIN_GEBAEUDEJAHR WOHNLAGE CAMEO_INTL_2015 KBA05_ANTG1 KBA05_ANTG2 KBA05_ANTG3 KBA05_ANTG4 KBA05_GBZ BALLRAUM EWDICHTE INNENSTADT GEBAEUDETYP_RASTER KKK MOBI_REGIO ONLINE_AFFINITAET REGIOTYP ... CAMEO_DEU_2015_1C CAMEO_DEU_2015_1D CAMEO_DEU_2015_1E CAMEO_DEU_2015_2A CAMEO_DEU_2015_2B CAMEO_DEU_2015_2C CAMEO_DEU_2015_2D CAMEO_DEU_2015_3A CAMEO_DEU_2015_3B CAMEO_DEU_2015_3C CAMEO_DEU_2015_3D CAMEO_DEU_2015_4A CAMEO_DEU_2015_4B CAMEO_DEU_2015_4C CAMEO_DEU_2015_4D CAMEO_DEU_2015_4E CAMEO_DEU_2015_5A CAMEO_DEU_2015_5B CAMEO_DEU_2015_5C CAMEO_DEU_2015_5D CAMEO_DEU_2015_5E CAMEO_DEU_2015_5F CAMEO_DEU_2015_6A CAMEO_DEU_2015_6B CAMEO_DEU_2015_6C CAMEO_DEU_2015_6D CAMEO_DEU_2015_6E CAMEO_DEU_2015_6F CAMEO_DEU_2015_7A CAMEO_DEU_2015_7B CAMEO_DEU_2015_7C CAMEO_DEU_2015_7D CAMEO_DEU_2015_7E CAMEO_DEU_2015_8A CAMEO_DEU_2015_8B CAMEO_DEU_2015_8C CAMEO_DEU_2015_8D CAMEO_DEU_2015_9A CAMEO_DEU_2015_9B CAMEO_DEU_2015_9C CAMEO_DEU_2015_9D CAMEO_DEU_2015_9E DECADE_40s DECADE_50s DECADE_60s DECADE_70s DECADE_80s DECADE_90s MOVEMENT_MAINSTREAM MOVEMENT_AVANTGARDE
691057 3.0 2.0 2.0 4.0 2.0 3.0 2.0 3.0 5.0 2.0 5.0 2.0 1.0 3.0 3.0 4.0 4.0 6.0 1.0 4.0 7.0 7.0 7.0 4.0 4.0 14.0 1.0 0.0 5.0 NaN 8.0 3.0 0.0 3.0 1995.0 4.0 43.0 1.0 0.0 1.0 1.0 3.0 7.0 5.0 2.0 2.0 NaN 2.0 1.0 NaN ... 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0
367638 4.0 2.0 2.0 5.0 2.0 2.0 5.0 1.0 6.0 2.0 5.0 2.0 2.0 1.0 3.0 2.0 7.0 7.0 1.0 3.0 6.0 5.0 6.0 2.0 1.0 8.0 1.0 0.0 6.0 6.0 9.0 3.0 0.0 1.0 1992.0 3.0 43.0 1.0 0.0 3.0 0.0 2.0 4.0 4.0 6.0 3.0 4.0 2.0 0.0 7.0 ... 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0
35929 4.0 3.0 2.0 4.0 1.0 3.0 3.0 2.0 7.0 2.0 5.0 5.0 1.0 1.0 3.0 2.0 7.0 7.0 1.0 2.0 6.0 5.0 6.0 1.0 1.0 14.0 1.0 0.0 3.0 4.0 9.0 9.0 0.0 2.0 1991.0 1.0 13.0 1.0 2.0 1.0 0.0 3.0 1.0 6.0 2.0 3.0 1.0 3.0 1.0 1.0 ... 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1
500495 4.0 5.0 2.0 4.0 2.0 3.0 1.0 2.0 11.0 3.0 5.0 6.0 6.0 3.0 1.0 7.0 7.0 7.0 6.0 3.0 3.0 3.0 3.0 2.0 2.0 13.0 1.0 0.0 5.0 4.0 9.0 1.0 0.0 2.0 1992.0 3.0 44.0 2.0 1.0 0.0 0.0 4.0 3.0 6.0 3.0 4.0 4.0 5.0 1.0 5.0 ... 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0
741306 4.0 2.0 5.0 1.0 3.0 1.0 4.0 2.0 2.0 1.0 3.0 3.0 6.0 2.0 4.0 6.0 5.0 3.0 4.0 3.0 3.0 3.0 3.0 1.0 4.0 17.0 1.0 0.0 6.0 5.0 8.0 47.0 0.0 1.0 1992.0 5.0 51.0 0.0 0.0 0.0 2.0 1.0 1.0 6.0 2.0 2.0 3.0 1.0 2.0 6.0 ... 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0
162881 3.0 4.0 2.0 4.0 1.0 2.0 2.0 3.0 13.0 3.0 5.0 6.0 6.0 4.0 4.0 7.0 6.0 4.0 5.0 2.0 5.0 5.0 3.0 4.0 2.0 NaN 1.0 0.0 4.0 5.0 8.0 3.0 0.0 1.0 1992.0 4.0 34.0 1.0 4.0 0.0 0.0 3.0 1.0 6.0 2.0 3.0 3.0 3.0 1.0 6.0 ... 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1
767156 4.0 5.0 1.0 5.0 1.0 1.0 3.0 1.0 12.0 3.0 5.0 1.0 2.0 1.0 1.0 5.0 7.0 7.0 1.0 2.0 6.0 5.0 6.0 1.0 1.0 8.0 1.0 0.0 3.0 6.0 9.0 1.0 0.0 1.0 1992.0 3.0 13.0 4.0 0.0 0.0 0.0 4.0 2.0 5.0 4.0 4.0 4.0 5.0 4.0 5.0 ... 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0
578423 1.0 4.0 3.0 1.0 4.0 3.0 1.0 2.0 27.0 8.0 3.0 7.0 7.0 7.0 5.0 6.0 4.0 4.0 7.0 4.0 4.0 4.0 1.0 4.0 5.0 17.0 2.0 0.0 2.0 1.0 9.0 2.0 0.0 5.0 1996.0 7.0 14.0 4.0 0.0 0.0 0.0 4.0 3.0 2.0 6.0 4.0 NaN 5.0 4.0 NaN ... 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0
678304 3.0 3.0 1.0 5.0 1.0 2.0 4.0 2.0 6.0 2.0 4.0 2.0 3.0 3.0 3.0 2.0 6.0 6.0 1.0 4.0 6.0 6.0 5.0 3.0 3.0 10.0 1.0 0.0 3.0 6.0 4.0 10.0 0.0 3.0 1992.0 7.0 24.0 1.0 3.0 0.0 0.0 3.0 7.0 1.0 4.0 4.0 2.0 3.0 4.0 3.0 ... 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0
403741 3.0 5.0 2.0 3.0 3.0 3.0 1.0 3.0 36.0 12.0 3.0 6.0 5.0 4.0 1.0 7.0 6.0 4.0 5.0 2.0 1.0 5.0 3.0 3.0 4.0 21.0 5.0 0.0 1.0 4.0 9.0 1.0 0.0 5.0 1992.0 7.0 22.0 3.0 0.0 0.0 0.0 4.0 6.0 1.0 8.0 2.0 4.0 4.0 3.0 6.0 ... 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1

10 rows × 207 columns

4.3. CAMEO_INTL_2015
German CAMEO: Wealth / Life Stage Typology, mapped to international code

-1: unknown
11: Wealthy Households - Pre-Family Couples & Singles
12: Wealthy Households - Young Couples With Children
13: Wealthy Households - Families With School Age Children
14: Wealthy Households - Older Families & Mature Couples
15: Wealthy Households - Elders In Retirement
21: Prosperous Households - Pre-Family Couples & Singles
22: Prosperous Households - Young Couples With Children
23: Prosperous Households - Families With School Age Children
24: Prosperous Households - Older Families & Mature Couples
25: Prosperous Households - Elders In Retirement
31: Comfortable Households - Pre-Family Couples & Singles
32: Comfortable Households - Young Couples With Children
33: Comfortable Households - Families With School Age Children
34: Comfortable Households - Older Families & Mature Couples
35: Comfortable Households - Elders In Retirement
41: Less Affluent Households - Pre-Family Couples & Singles
42: Less Affluent Households - Young Couples With Children
43: Less Affluent Households - Families With School Age Children
44: Less Affluent Households - Older Families & Mature Couples
45: Less Affluent Households - Elders In Retirement
51: Poorer Households - Pre-Family Couples & Singles
52: Poorer Households - Young Couples With Children
53: Poorer Households - Families With School Age Children
54: Poorer Households - Older Families & Mature Couples
55: Poorer Households - Elders In Retirement
XX: unknown
In [34]:
# Investigate "CAMEO_INTL_2015" and engineer two new variables.

# Split into two columns with 10s and 1s values
df_subset['CAMEO_WEALTH'], df_subset['CAMEO_LIFESTAGE'] = divmod(
    pd.to_numeric(df_subset['CAMEO_INTL_2015'], downcast='integer'), 10)

# Drop the original column
df_subset = df_subset.drop(columns=['CAMEO_INTL_2015'])

# And then one-hot encode the new columns
# One-hot encode the multi-level categoricals and string columns
df_subset = pd.get_dummies(
    df_subset,
    columns=[
        'CAMEO_WEALTH', 'CAMEO_LIFESTAGE'
    ],
    prefix_sep='_')

Discussion 1.2.2: Engineer Mixed-Type Features

I converted PRAEGENDE_JUGENDJAHRE into two new one-hot encoded features that capture decade and movement. I then split CAMEO_INTL_2015 into two new one-hot encoded features using the first digit (wealth) and the second digit (lifestage).

In [35]:
df_subset.dtypes
Out[35]:
ALTERSKATEGORIE_GROB     float64
FINANZ_MINIMALIST        float64
FINANZ_SPARER            float64
FINANZ_VORSORGER         float64
FINANZ_ANLEGER           float64
FINANZ_UNAUFFAELLIGER    float64
FINANZ_HAUSBAUER         float64
HEALTH_TYP               float64
LP_LEBENSPHASE_FEIN      float64
LP_LEBENSPHASE_GROB      float64
RETOURTYP_BK_S           float64
SEMIO_SOZ                float64
SEMIO_FAM                float64
SEMIO_REL                float64
SEMIO_MAT                float64
SEMIO_VERT               float64
SEMIO_LUST               float64
SEMIO_ERL                float64
SEMIO_KULT               float64
SEMIO_RAT                float64
SEMIO_KRIT               float64
SEMIO_DOM                float64
SEMIO_KAEM               float64
SEMIO_PFLICHT            float64
SEMIO_TRADV              float64
ALTER_HH                 float64
ANZ_PERSONEN             float64
ANZ_TITEL                float64
HH_EINKOMMEN_SCORE       float64
W_KEIT_KIND_HH           float64
WOHNDAUER_2008           float64
ANZ_HAUSHALTE_AKTIV      float64
ANZ_HH_TITEL             float64
KONSUMNAEHE              float64
MIN_GEBAEUDEJAHR         float64
WOHNLAGE                 float64
KBA05_ANTG1              float64
KBA05_ANTG2              float64
KBA05_ANTG3              float64
KBA05_ANTG4              float64
KBA05_GBZ                float64
BALLRAUM                 float64
EWDICHTE                 float64
INNENSTADT               float64
GEBAEUDETYP_RASTER       float64
KKK                      float64
MOBI_REGIO               float64
ONLINE_AFFINITAET        float64
REGIOTYP                 float64
KBA13_ANZAHL_PKW         float64
                          ...   
CAMEO_DEU_2015_3D          uint8
CAMEO_DEU_2015_4A          uint8
CAMEO_DEU_2015_4B          uint8
CAMEO_DEU_2015_4C          uint8
CAMEO_DEU_2015_4D          uint8
CAMEO_DEU_2015_4E          uint8
CAMEO_DEU_2015_5A          uint8
CAMEO_DEU_2015_5B          uint8
CAMEO_DEU_2015_5C          uint8
CAMEO_DEU_2015_5D          uint8
CAMEO_DEU_2015_5E          uint8
CAMEO_DEU_2015_5F          uint8
CAMEO_DEU_2015_6A          uint8
CAMEO_DEU_2015_6B          uint8
CAMEO_DEU_2015_6C          uint8
CAMEO_DEU_2015_6D          uint8
CAMEO_DEU_2015_6E          uint8
CAMEO_DEU_2015_6F          uint8
CAMEO_DEU_2015_7A          uint8
CAMEO_DEU_2015_7B          uint8
CAMEO_DEU_2015_7C          uint8
CAMEO_DEU_2015_7D          uint8
CAMEO_DEU_2015_7E          uint8
CAMEO_DEU_2015_8A          uint8
CAMEO_DEU_2015_8B          uint8
CAMEO_DEU_2015_8C          uint8
CAMEO_DEU_2015_8D          uint8
CAMEO_DEU_2015_9A          uint8
CAMEO_DEU_2015_9B          uint8
CAMEO_DEU_2015_9C          uint8
CAMEO_DEU_2015_9D          uint8
CAMEO_DEU_2015_9E          uint8
DECADE_40s                 int64
DECADE_50s                 int64
DECADE_60s                 int64
DECADE_70s                 int64
DECADE_80s                 int64
DECADE_90s                 int64
MOVEMENT_MAINSTREAM        int64
MOVEMENT_AVANTGARDE        int64
CAMEO_WEALTH_1.0           uint8
CAMEO_WEALTH_2.0           uint8
CAMEO_WEALTH_3.0           uint8
CAMEO_WEALTH_4.0           uint8
CAMEO_WEALTH_5.0           uint8
CAMEO_LIFESTAGE_1.0        uint8
CAMEO_LIFESTAGE_2.0        uint8
CAMEO_LIFESTAGE_3.0        uint8
CAMEO_LIFESTAGE_4.0        uint8
CAMEO_LIFESTAGE_5.0        uint8
Length: 216, dtype: object

Step 1.2.3: Complete Feature Selection

In order to finish this step up, you need to make sure that your data frame now only has the columns that you want to keep. To summarize, the dataframe should consist of the following:

  • All numeric, interval, and ordinal type columns from the original dataset.
  • Binary categorical features (all numerically-encoded).
  • Engineered features from other multi-level categorical features and mixed features.

Make sure that for any new columns that you have engineered, that you've excluded the original columns from the final dataset. Otherwise, their values will interfere with the analysis later on the project. For example, you should not keep "PRAEGENDE_JUGENDJAHRE", since its values won't be useful for the algorithm: only the values derived from it in the engineered features you created should be retained. As a reminder, your data should only be from the subset with few or no missing values.

Step 1.3: Create a Cleaning Function

Even though you've finished cleaning up the general population demographics data, it's important to look ahead to the future and realize that you'll need to perform the same cleaning steps on the customer demographics data. In this substep, complete the function below to execute the main feature selection, encoding, and re-engineering steps you performed above. Then, when it comes to looking at the customer data in Step 3, you can just run this function on that DataFrame to get the trimmed dataset in a single step.

In [36]:
def clean_data(df, feat_info):
    """
    Perform feature trimming, re-encoding, and engineering for demographics
    data

    INPUT: Demographics DataFrame
    OUTPUT: Trimmed and cleaned demographics DataFrame
    """

    # Identify missing or unknown data values and convert them to NaNs.
    df.loc[df['CAMEO_DEUG_2015'] == 'X'] = np.nan
    df.loc[df['CAMEO_DEU_2015'] == 'XX'] = np.nan
    df.loc[df['CAMEO_INTL_2015'] == 'XX'] = np.nan

    # Now convert two of the columns to numeric since strings are gone, keep _DEU_ as string
    df['CAMEO_DEUG_2015'] = pd.to_numeric(df['CAMEO_DEUG_2015'],
                                          errors='coerce')
    df['CAMEO_INTL_2015'] = pd.to_numeric(df['CAMEO_INTL_2015'],
                                          errors='coerce')

    # Iterate over the feat_info df - this is not the most efficient
    # way to do it, and I'd like to try to handle the string values
    # in one single for-loop as an improvement
    for index, row in feat_info.iterrows():
        attr = row['attribute']
        # Strip out the brackets and separate on comma
        values = row['missing_or_unknown'].replace('[',
                                                   '').replace(']',
                                                               '').split(',')
        for val in values:
            # We still have strings in here (X / XX) so ignore them
            if val not in ['', 'X', 'XX']:
                val = int(val)
                df.loc[df[attr] == val, attr] = np.nan

    # Create new one-hot encoded decade columns
    df['DECADE_40s'] = df['PRAEGENDE_JUGENDJAHRE'].apply(lambda x: 1 if x >= 1
                                                         and x <= 2 else 0)
    df['DECADE_50s'] = df['PRAEGENDE_JUGENDJAHRE'].apply(lambda x: 1 if x >= 3
                                                         and x <= 4 else 0)
    df['DECADE_60s'] = df['PRAEGENDE_JUGENDJAHRE'].apply(lambda x: 1 if x >= 5
                                                         and x <= 7 else 0)
    df['DECADE_70s'] = df['PRAEGENDE_JUGENDJAHRE'].apply(lambda x: 1 if x >= 8
                                                         and x <= 9 else 0)
    df['DECADE_80s'] = df['PRAEGENDE_JUGENDJAHRE'].apply(lambda x: 1 if x >= 10
                                                         and x <= 13 else 0)
    df['DECADE_90s'] = df['PRAEGENDE_JUGENDJAHRE'].apply(lambda x: 1 if x >= 14
                                                         and x <= 15 else 0)

    # Create new one-hot encoded movement columns
    df['MOVEMENT_MAINSTREAM'] = df['PRAEGENDE_JUGENDJAHRE'].apply(
        lambda x: 1 if x in [1, 3, 5, 8, 10, 12, 14] else 0)
    df['MOVEMENT_AVANTGARDE'] = df['PRAEGENDE_JUGENDJAHRE'].apply(
        lambda x: 1 if x in [2, 4, 6, 7, 9, 11, 13, 15] else 0)

    # Drop the rows with missing values
    df = df.query('HEALTH_TYP != "NaN"')

    # Split CAMEO_WEALTH into two columns with 10s and 1s values
    df['CAMEO_WEALTH'], df['CAMEO_LIFESTAGE'] = divmod(
        pd.to_numeric(df['CAMEO_INTL_2015'], downcast='integer'), 10)

    df = pd.get_dummies(
        df,
        columns=[
            'ANREDE_KZ', 'CJT_GESAMTTYP', 'FINANZTYP', 'GFK_URLAUBERTYP',
            'GREEN_AVANTGARDE', 'LP_FAMILIE_FEIN', 'LP_FAMILIE_GROB',
            'LP_STATUS_FEIN', 'LP_STATUS_GROB', 'NATIONALITAET_KZ',
            'SHOPPER_TYP', 'SOHO_KZ', 'VERS_TYP', 'ZABEOTYP', 'GEBAEUDETYP',
            'OST_WEST_KZ', 'CAMEO_DEUG_2015', 'CAMEO_DEU_2015', 'CAMEO_WEALTH',
            'CAMEO_LIFESTAGE'
        ],
        prefix_sep='_')

    # Drop unneeded columns
    df = df.drop(columns=[
        'TITEL_KZ', 'AGER_TYP', 'KK_KUNDENTYP', 'KBA05_BAUMAX', 'GEBURTSJAHR',
        'CAMEO_INTL_2015', 'PRAEGENDE_JUGENDJAHRE'
    ])

    return df
In [37]:
azdias = pd.read_csv('Udacity_AZDIAS_Subset.csv', sep=';')
azdias = clean_data(azdias, feat_info)
/anaconda3/lib/python3.7/site-packages/ipykernel_launcher.py:61: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
In [38]:
# Because I optimized the function, our columns will be in different orders
# reorder them alphabetically so we can compare them properly
df_subset = df_subset.reindex(sorted(df_subset.columns), axis=1)
azdias = azdias.reindex(sorted(azdias.columns), axis=1)
In [39]:
# Quick test to ensure our dataframes match, compare the first 100 rows
# of each. We expect no output if they match perfectly.
pd.concat([df_subset.head(100),
           azdias.head(100)]).drop_duplicates(keep=False)
Out[39]:
ALTERSKATEGORIE_GROB ALTER_HH ANREDE_KZ_1.0 ANREDE_KZ_2.0 ANZ_HAUSHALTE_AKTIV ANZ_HH_TITEL ANZ_PERSONEN ANZ_TITEL ARBEIT BALLRAUM CAMEO_DEUG_2015_1.0 CAMEO_DEUG_2015_2.0 CAMEO_DEUG_2015_3.0 CAMEO_DEUG_2015_4.0 CAMEO_DEUG_2015_5.0 CAMEO_DEUG_2015_6.0 CAMEO_DEUG_2015_7.0 CAMEO_DEUG_2015_8.0 CAMEO_DEUG_2015_9.0 CAMEO_DEU_2015_1A CAMEO_DEU_2015_1B CAMEO_DEU_2015_1C CAMEO_DEU_2015_1D CAMEO_DEU_2015_1E CAMEO_DEU_2015_2A CAMEO_DEU_2015_2B CAMEO_DEU_2015_2C CAMEO_DEU_2015_2D CAMEO_DEU_2015_3A CAMEO_DEU_2015_3B CAMEO_DEU_2015_3C CAMEO_DEU_2015_3D CAMEO_DEU_2015_4A CAMEO_DEU_2015_4B CAMEO_DEU_2015_4C CAMEO_DEU_2015_4D CAMEO_DEU_2015_4E CAMEO_DEU_2015_5A CAMEO_DEU_2015_5B CAMEO_DEU_2015_5C CAMEO_DEU_2015_5D CAMEO_DEU_2015_5E CAMEO_DEU_2015_5F CAMEO_DEU_2015_6A CAMEO_DEU_2015_6B CAMEO_DEU_2015_6C CAMEO_DEU_2015_6D CAMEO_DEU_2015_6E CAMEO_DEU_2015_6F CAMEO_DEU_2015_7A ... MOVEMENT_AVANTGARDE MOVEMENT_MAINSTREAM NATIONALITAET_KZ_1.0 NATIONALITAET_KZ_2.0 NATIONALITAET_KZ_3.0 ONLINE_AFFINITAET ORTSGR_KLS9 OST_WEST_KZ_O OST_WEST_KZ_W PLZ8_ANTG1 PLZ8_ANTG2 PLZ8_ANTG3 PLZ8_ANTG4 PLZ8_BAUMAX PLZ8_GBZ PLZ8_HHZ REGIOTYP RELAT_AB RETOURTYP_BK_S SEMIO_DOM SEMIO_ERL SEMIO_FAM SEMIO_KAEM SEMIO_KRIT SEMIO_KULT SEMIO_LUST SEMIO_MAT SEMIO_PFLICHT SEMIO_RAT SEMIO_REL SEMIO_SOZ SEMIO_TRADV SEMIO_VERT SHOPPER_TYP_0.0 SHOPPER_TYP_1.0 SHOPPER_TYP_2.0 SHOPPER_TYP_3.0 SOHO_KZ_0.0 SOHO_KZ_1.0 VERS_TYP_1.0 VERS_TYP_2.0 WOHNDAUER_2008 WOHNLAGE W_KEIT_KIND_HH ZABEOTYP_1.0 ZABEOTYP_2.0 ZABEOTYP_3.0 ZABEOTYP_4.0 ZABEOTYP_5.0 ZABEOTYP_6.0

0 rows × 216 columns

In [40]:
azdias.shape
Out[40]:
(779676, 216)
In [41]:
df_subset.shape
Out[41]:
(779676, 216)

Great! So now we know our function will apply the same the exact same transformations as we did above. We'll use azdias as our cleaned version of the demographics dataframe going into section 2.

Step 2: Feature Transformation

Step 2.1: Apply Feature Scaling

Before we apply dimensionality reduction techniques to the data, we need to perform feature scaling so that the principal component vectors are not influenced by the natural differences in scale for features. Starting from this part of the project, you'll want to keep an eye on the API reference page for sklearn to help you navigate to all of the classes and functions that you'll need. In this substep, you'll need to check the following:

  • sklearn requires that data not have missing values in order for its estimators to work properly. So, before applying the scaler to your data, make sure that you've cleaned the DataFrame of the remaining missing values. This can be as simple as just removing all data points with missing data, or applying an Imputer to replace all missing values. You might also try a more complicated procedure where you temporarily remove missing values in order to compute the scaling parameters before re-introducing those missing values and applying imputation. Think about how much missing data you have and what possible effects each approach might have on your analysis, and justify your decision in the discussion section below.
  • For the actual scaling function, a StandardScaler instance is suggested, scaling each feature to mean 0 and standard deviation 1.
  • For these classes, you can make use of the .fit_transform() method to both fit a procedure to the data as well as apply the transformation to the data at the same time. Don't forget to keep the fit sklearn objects handy, since you'll be applying them to the customer demographics data towards the end of the project.
In [42]:
# If you've not yet cleaned the dataset of all NaN values, then investigate and
# do that now.
azdias.isnull().sum().sort_values(ascending=False).head(40)
Out[42]:
ALTER_HH               218310
KKK                     81335
REGIOTYP                81335
W_KEIT_KIND_HH          59512
KBA05_ANTG2             57407
KBA05_ANTG3             57407
KBA05_ANTG4             57407
KBA05_GBZ               57407
MOBI_REGIO              57407
KBA05_ANTG1             57407
PLZ8_BAUMAX             40959
PLZ8_ANTG2              40959
PLZ8_HHZ                40959
PLZ8_GBZ                40959
PLZ8_ANTG4              40959
PLZ8_ANTG3              40959
PLZ8_ANTG1              40959
KBA13_ANZAHL_PKW        30676
LP_LEBENSPHASE_FEIN     30507
LP_LEBENSPHASE_GROB     30506
ANZ_HAUSHALTE_AKTIV     24940
RELAT_AB                22707
ARBEIT                  22707
ORTSGR_KLS9             22611
ANZ_HH_TITEL            22369
EWDICHTE                19268
BALLRAUM                19268
INNENSTADT              19268
GEBAEUDETYP_RASTER      18691
WOHNLAGE                18684
MIN_GEBAEUDEJAHR        18684
HH_EINKOMMEN_SCORE      17452
RETOURTYP_BK_S           4575
ONLINE_AFFINITAET        4575
KONSUMNAEHE               458
CAMEO_LIFESTAGE_4.0         0
CAMEO_LIFESTAGE_3.0         0
CAMEO_LIFESTAGE_2.0         0
CAMEO_LIFESTAGE_1.0         0
CAMEO_DEU_2015_9E           0
dtype: int64

I've confirmed that none of the columns with NaNs are categorical. So we will replace NaNs with median values.

In [43]:
# I'm going to replace missing values with the median for these columns
# that contain missing values
impute = SimpleImputer(missing_values=np.nan, strategy='median')

azdias[[
    'ALTER_HH', 'KKK', 'REGIOTYP', 'W_KEIT_KIND_HH', 'KBA05_ANTG2',
    'KBA05_ANTG3', 'KBA05_ANTG4', 'KBA05_GBZ', 'MOBI_REGIO', 'KBA05_ANTG1',
    'PLZ8_BAUMAX', 'PLZ8_ANTG2', 'PLZ8_HHZ', 'PLZ8_GBZ', 'PLZ8_ANTG4',
    'PLZ8_ANTG3', 'PLZ8_ANTG1', 'KBA13_ANZAHL_PKW', 'LP_LEBENSPHASE_FEIN',
    'LP_LEBENSPHASE_GROB', 'ANZ_HAUSHALTE_AKTIV', 'RELAT_AB', 'ARBEIT',
    'ORTSGR_KLS9', 'ANZ_HH_TITEL', 'EWDICHTE', 'BALLRAUM', 'INNENSTADT',
    'GEBAEUDETYP_RASTER', 'WOHNLAGE', 'MIN_GEBAEUDEJAHR', 'HH_EINKOMMEN_SCORE',
    'RETOURTYP_BK_S', 'ONLINE_AFFINITAET', 'KONSUMNAEHE'
]] = impute.fit_transform(azdias[[
    'ALTER_HH', 'KKK', 'REGIOTYP', 'W_KEIT_KIND_HH', 'KBA05_ANTG2',
    'KBA05_ANTG3', 'KBA05_ANTG4', 'KBA05_GBZ', 'MOBI_REGIO', 'KBA05_ANTG1',
    'PLZ8_BAUMAX', 'PLZ8_ANTG2', 'PLZ8_HHZ', 'PLZ8_GBZ', 'PLZ8_ANTG4',
    'PLZ8_ANTG3', 'PLZ8_ANTG1', 'KBA13_ANZAHL_PKW', 'LP_LEBENSPHASE_FEIN',
    'LP_LEBENSPHASE_GROB', 'ANZ_HAUSHALTE_AKTIV', 'RELAT_AB', 'ARBEIT',
    'ORTSGR_KLS9', 'ANZ_HH_TITEL', 'EWDICHTE', 'BALLRAUM', 'INNENSTADT',
    'GEBAEUDETYP_RASTER', 'WOHNLAGE', 'MIN_GEBAEUDEJAHR', 'HH_EINKOMMEN_SCORE',
    'RETOURTYP_BK_S', 'ONLINE_AFFINITAET', 'KONSUMNAEHE'
]])
In [44]:
# Apply feature scaling to the general population demographics data.
scaler = preprocessing.StandardScaler() 
azdias_scaled = pd.DataFrame(scaler.fit_transform(azdias))
In [45]:
# Add column names again
azdias_scaled.columns = azdias.columns
azdias_scaled.index = azdias.index
azdias_scaled = pd.DataFrame(azdias_scaled, columns=list(azdias))
In [46]:
# Let's take a look - I'm expecting stdevs of 1.0 here
azdias_scaled.describe()
Out[46]:
ALTERSKATEGORIE_GROB ALTER_HH ANREDE_KZ_1.0 ANREDE_KZ_2.0 ANZ_HAUSHALTE_AKTIV ANZ_HH_TITEL ANZ_PERSONEN ANZ_TITEL ARBEIT BALLRAUM CAMEO_DEUG_2015_1.0 CAMEO_DEUG_2015_2.0 CAMEO_DEUG_2015_3.0 CAMEO_DEUG_2015_4.0 CAMEO_DEUG_2015_5.0 CAMEO_DEUG_2015_6.0 CAMEO_DEUG_2015_7.0 CAMEO_DEUG_2015_8.0 CAMEO_DEUG_2015_9.0 CAMEO_DEU_2015_1A CAMEO_DEU_2015_1B CAMEO_DEU_2015_1C CAMEO_DEU_2015_1D CAMEO_DEU_2015_1E CAMEO_DEU_2015_2A CAMEO_DEU_2015_2B CAMEO_DEU_2015_2C CAMEO_DEU_2015_2D CAMEO_DEU_2015_3A CAMEO_DEU_2015_3B CAMEO_DEU_2015_3C CAMEO_DEU_2015_3D CAMEO_DEU_2015_4A CAMEO_DEU_2015_4B CAMEO_DEU_2015_4C CAMEO_DEU_2015_4D CAMEO_DEU_2015_4E CAMEO_DEU_2015_5A CAMEO_DEU_2015_5B CAMEO_DEU_2015_5C CAMEO_DEU_2015_5D CAMEO_DEU_2015_5E CAMEO_DEU_2015_5F CAMEO_DEU_2015_6A CAMEO_DEU_2015_6B CAMEO_DEU_2015_6C CAMEO_DEU_2015_6D CAMEO_DEU_2015_6E CAMEO_DEU_2015_6F CAMEO_DEU_2015_7A ... MOVEMENT_AVANTGARDE MOVEMENT_MAINSTREAM NATIONALITAET_KZ_1.0 NATIONALITAET_KZ_2.0 NATIONALITAET_KZ_3.0 ONLINE_AFFINITAET ORTSGR_KLS9 OST_WEST_KZ_O OST_WEST_KZ_W PLZ8_ANTG1 PLZ8_ANTG2 PLZ8_ANTG3 PLZ8_ANTG4 PLZ8_BAUMAX PLZ8_GBZ PLZ8_HHZ REGIOTYP RELAT_AB RETOURTYP_BK_S SEMIO_DOM SEMIO_ERL SEMIO_FAM SEMIO_KAEM SEMIO_KRIT SEMIO_KULT SEMIO_LUST SEMIO_MAT SEMIO_PFLICHT SEMIO_RAT SEMIO_REL SEMIO_SOZ SEMIO_TRADV SEMIO_VERT SHOPPER_TYP_0.0 SHOPPER_TYP_1.0 SHOPPER_TYP_2.0 SHOPPER_TYP_3.0 SOHO_KZ_0.0 SOHO_KZ_1.0 VERS_TYP_1.0 VERS_TYP_2.0 WOHNDAUER_2008 WOHNLAGE W_KEIT_KIND_HH ZABEOTYP_1.0 ZABEOTYP_2.0 ZABEOTYP_3.0 ZABEOTYP_4.0 ZABEOTYP_5.0 ZABEOTYP_6.0
count 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 ... 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05 7.796760e+05
mean -1.124923e-15 6.595059e-15 -9.190568e-15 9.190568e-15 -5.600942e-16 5.467112e-15 3.923353e-15 -6.750002e-15 -6.157756e-14 1.829699e-15 -1.005381e-15 1.262638e-14 7.726124e-15 -1.651706e-14 6.606468e-15 1.269363e-15 1.913507e-15 -7.641788e-15 -2.273639e-15 -1.456450e-14 -9.261969e-15 -9.943254e-16 1.506644e-14 -1.245323e-14 7.414509e-15 3.664642e-15 9.954786e-15 -8.925212e-15 -1.199630e-14 5.371574e-15 1.387979e-14 -2.886123e-14 1.037334e-14 1.008914e-14 -1.074528e-15 -8.210771e-15 -1.990010e-15 -6.478748e-15 1.384931e-14 1.534011e-14 -2.119196e-15 -4.457534e-16 8.285563e-15 5.490150e-15 2.063162e-14 -1.428587e-15 -3.697055e-15 -8.380961e-15 -1.239302e-15 -4.790802e-17 ... 2.187924e-14 9.521024e-15 6.961852e-15 -7.616448e-15 -7.854861e-16 2.115796e-15 -8.926274e-15 -8.222359e-14 1.298779e-13 -1.470384e-14 -2.899269e-15 -5.762212e-15 -7.887201e-15 -1.515402e-14 2.165742e-14 1.314146e-14 -2.210297e-15 -6.992520e-15 8.008752e-16 4.801776e-15 -4.754304e-15 2.434580e-16 -8.327769e-16 -8.010821e-16 -9.963581e-16 1.069370e-15 6.504782e-15 4.472938e-15 -1.014263e-16 -1.896999e-15 4.418077e-15 3.737301e-15 1.568064e-15 -7.954635e-15 -4.607047e-15 -1.044928e-14 2.992372e-15 1.673996e-15 -1.673703e-15 -2.696704e-14 2.696792e-14 7.007025e-15 -7.720100e-15 -1.345116e-15 -1.008371e-14 1.206350e-14 -2.009657e-14 -7.400684e-15 -2.889253e-14 -4.518278e-15
std 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 ... 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00 1.000001e+00
min -1.745147e+00 -4.475077e+00 -9.762614e-01 -1.024316e+00 -4.650221e-01 -1.223951e-01 -1.502030e+00 -5.971083e-02 -2.184686e+00 -1.481057e+00 -2.165652e-01 -3.396851e-01 -3.474804e-01 -3.844336e-01 -2.696816e-01 -3.860407e-01 -3.242065e-01 -4.408797e-01 -3.844622e-01 -1.163797e-01 -7.108541e-02 -7.316966e-02 -1.226992e-01 -7.931355e-02 -1.294606e-01 -1.404285e-01 -1.575441e-01 -2.130200e-01 -1.151966e-01 -9.507805e-02 -2.119254e-01 -2.111909e-01 -2.070147e-01 -1.062898e-01 -2.510804e-01 -1.035724e-01 -8.137527e-02 -1.234617e-01 -1.135855e-01 -1.113224e-01 -1.359070e-01 -6.641490e-02 -7.284117e-02 -9.060175e-02 -2.729455e-01 -1.358630e-01 -8.675995e-02 -1.427004e-01 -8.194826e-02 -2.097787e-01 ... -5.314845e-01 -1.779064e+00 -2.645945e+00 -3.011670e-01 -2.089276e-01 -1.775659e+00 -1.873822e+00 -5.166980e-01 -1.805841e+00 -2.372291e+00 -3.122408e+00 -1.661899e+00 -9.956967e-01 -6.162249e-01 -2.182570e+00 -2.685436e+00 -2.019063e+00 -1.534633e+00 -1.673055e+00 -1.903310e+00 -1.972171e+00 -1.586195e+00 -1.728307e+00 -1.975345e+00 -1.563561e+00 -1.536556e+00 -1.488463e+00 -1.710966e+00 -1.729584e+00 -1.545234e+00 -1.621797e+00 -1.542594e+00 -1.750564e+00 -4.422215e-01 -6.964059e-01 -6.019893e-01 -5.678673e-01 -1.085518e+01 -9.212192e-02 -9.778990e-01 -1.022601e+00 -3.590550e+00 -2.078380e+00 -1.832800e+00 -4.282439e-01 -2.098953e-01 -7.384395e-01 -5.852039e-01 -3.421320e-01 -3.146163e-01
25% -7.754614e-01 -4.601135e-01 -9.762614e-01 -1.024316e+00 -3.991274e-01 -1.223951e-01 -6.355161e-01 -5.971083e-02 -1.608778e-01 -1.017322e+00 -2.165652e-01 -3.396851e-01 -3.474804e-01 -3.844336e-01 -2.696816e-01 -3.860407e-01 -3.242065e-01 -4.408797e-01 -3.844622e-01 -1.163797e-01 -7.108541e-02 -7.316966e-02 -1.226992e-01 -7.931355e-02 -1.294606e-01 -1.404285e-01 -1.575441e-01 -2.130200e-01 -1.151966e-01 -9.507805e-02 -2.119254e-01 -2.111909e-01 -2.070147e-01 -1.062898e-01 -2.510804e-01 -1.035724e-01 -8.137527e-02 -1.234617e-01 -1.135855e-01 -1.113224e-01 -1.359070e-01 -6.641490e-02 -7.284117e-02 -9.060175e-02 -2.729455e-01 -1.358630e-01 -8.675995e-02 -1.427004e-01 -8.194826e-02 -2.097787e-01 ... -5.314845e-01 5.620933e-01 3.779368e-01 -3.011670e-01 -2.089276e-01 -1.132006e+00 -5.532322e-01 -5.166980e-01 5.537587e-01 -2.637213e-01 -8.944499e-01 -6.267051e-01 -9.956967e-01 -6.162249e-01 -3.386062e-01 -5.998021e-01 -8.724677e-01 -7.888906e-01 -9.815287e-01 -8.279402e-01 -8.708349e-01 -1.072811e+00 -6.708361e-01 -8.579867e-01 -5.600005e-01 -1.060544e+00 -9.747466e-01 -6.100878e-01 -5.184506e-01 -4.686333e-01 -1.108950e+00 -9.848115e-01 -1.231784e+00 -4.422215e-01 -6.964059e-01 -6.019893e-01 -5.678673e-01 9.212192e-02 -9.212192e-02 -9.778990e-01 -1.022601e+00 4.772453e-02 -5.344781e-01 -6.633084e-01 -4.282439e-01 -2.098953e-01 -7.384395e-01 -5.852039e-01 -3.421320e-01 -3.146163e-01
50% 1.942242e-01 1.575732e-01 -9.762614e-01 9.762614e-01 -2.673380e-01 -1.223951e-01 -6.355161e-01 -5.971083e-02 -1.608778e-01 3.738836e-01 -2.165652e-01 -3.396851e-01 -3.474804e-01 -3.844336e-01 -2.696816e-01 -3.860407e-01 -3.242065e-01 -4.408797e-01 -3.844622e-01 -1.163797e-01 -7.108541e-02 -7.316966e-02 -1.226992e-01 -7.931355e-02 -1.294606e-01 -1.404285e-01 -1.575441e-01 -2.130200e-01 -1.151966e-01 -9.507805e-02 -2.119254e-01 -2.111909e-01 -2.070147e-01 -1.062898e-01 -2.510804e-01 -1.035724e-01 -8.137527e-02 -1.234617e-01 -1.135855e-01 -1.113224e-01 -1.359070e-01 -6.641490e-02 -7.284117e-02 -9.060175e-02 -2.729455e-01 -1.358630e-01 -8.675995e-02 -1.427004e-01 -8.194826e-02 -2.097787e-01 ... -5.314845e-01 5.620933e-01 3.779368e-01 -3.011670e-01 -2.089276e-01 1.553023e-01 -1.130358e-01 -5.166980e-01 5.537587e-01 -2.637213e-01 2.195294e-01 4.084885e-01 4.133184e-01 -6.162249e-01 -3.386062e-01 -5.998021e-01 2.741273e-01 -4.314768e-02 4.015231e-01 2.474296e-01 -3.201666e-01 -4.604333e-02 -1.421005e-01 2.593713e-01 -5.822038e-02 -1.085186e-01 5.268569e-02 -5.964863e-02 8.711587e-02 6.966707e-02 -8.325647e-02 1.307543e-01 3.245567e-01 -4.422215e-01 -6.964059e-01 -6.019893e-01 -5.678673e-01 9.212192e-02 -9.212192e-02 -9.778990e-01 9.778990e-01 5.674780e-01 -5.344781e-01 -7.856250e-02 -4.282439e-01 -2.098953e-01 -7.384395e-01 -5.852039e-01 -3.421320e-01 -3.146163e-01
75% 1.163910e+00 4.664166e-01 1.024316e+00 9.762614e-01 6.213555e-02 -1.223951e-01 2.309973e-01 -5.971083e-02 8.510262e-01 8.376187e-01 -2.165652e-01 -3.396851e-01 -3.474804e-01 -3.844336e-01 -2.696816e-01 -3.860407e-01 -3.242065e-01 -4.408797e-01 -3.844622e-01 -1.163797e-01 -7.108541e-02 -7.316966e-02 -1.226992e-01 -7.931355e-02 -1.294606e-01 -1.404285e-01 -1.575441e-01 -2.130200e-01 -1.151966e-01 -9.507805e-02 -2.119254e-01 -2.111909e-01 -2.070147e-01 -1.062898e-01 -2.510804e-01 -1.035724e-01 -8.137527e-02 -1.234617e-01 -1.135855e-01 -1.113224e-01 -1.359070e-01 -6.641490e-02 -7.284117e-02 -9.060175e-02 -2.729455e-01 -1.358630e-01 -8.675995e-02 -1.427004e-01 -8.194826e-02 -2.097787e-01 ... -5.314845e-01 5.620933e-01 3.779368e-01 -3.011670e-01 -2.089276e-01 7.989562e-01 7.673571e-01 -5.166980e-01 5.537587e-01 7.905634e-01 2.195294e-01 4.084885e-01 4.133184e-01 8.432460e-02 5.833759e-01 4.430150e-01 8.474248e-01 7.025952e-01 1.093049e+00 7.851145e-01 7.811700e-01 9.807245e-01 9.153707e-01 8.180503e-01 9.453398e-01 8.435065e-01 1.080118e+00 1.041230e+00 6.926824e-01 6.079675e-01 9.424372e-01 6.885372e-01 8.433369e-01 -4.422215e-01 1.435944e+00 1.661159e+00 -5.678673e-01 9.212192e-02 -9.212192e-02 1.022601e+00 9.778990e-01 5.674780e-01 4.947899e-01 1.090929e+00 -4.282439e-01 -2.098953e-01 1.354207e+00 1.708806e+00 -3.421320e-01 -3.146163e-01
max 1.163910e+00 1.701790e+00 1.024316e+00 9.762614e-01 3.867644e+01 7.249245e+01 3.749107e+01 5.920840e+01 1.862930e+00 1.301354e+00 4.617547e+00 2.943903e+00 2.877860e+00 2.601229e+00 3.708076e+00 2.590400e+00 3.084454e+00 2.268192e+00 2.601036e+00 8.592563e+00 1.406758e+01 1.366687e+01 8.150012e+00 1.260819e+01 7.724360e+00 7.121061e+00 6.347428e+00 4.694395e+00 8.680811e+00 1.051767e+01 4.718641e+00 4.735053e+00 4.830575e+00 9.408243e+00 3.982788e+00 9.655085e+00 1.228875e+01 8.099680e+00 8.803937e+00 8.982917e+00 7.357972e+00 1.505686e+01 1.372850e+01 1.103731e+01 3.663735e+00 7.360358e+00 1.152606e+01 7.007689e+00 1.220282e+01 4.766927e+00 ... 1.881523e+00 5.620933e-01 3.779368e-01 3.320417e+00 4.786346e+00 1.442610e+00 1.647750e+00 1.935366e+00 5.537587e-01 1.844848e+00 1.333509e+00 1.443682e+00 1.822334e+00 2.185973e+00 1.505358e+00 1.485832e+00 1.420722e+00 1.448338e+00 1.093049e+00 1.322799e+00 1.331838e+00 1.494108e+00 1.444106e+00 1.376729e+00 1.447120e+00 1.319519e+00 1.593834e+00 1.591669e+00 1.903815e+00 1.684568e+00 1.455284e+00 1.804103e+00 1.362117e+00 2.261310e+00 1.435944e+00 1.661159e+00 1.760975e+00 9.212192e-02 1.085518e+01 1.022601e+00 9.778990e-01 5.674780e-01 2.038692e+00 1.090929e+00 2.335118e+00 4.764279e+00 1.354207e+00 1.708806e+00 2.922848e+00 3.178474e+00

8 rows × 216 columns

Discussion 2.1: Apply Feature Scaling

I found this section to be one of the most challenging in the project since it required me to save and restore the column names and index, and that wasn't obvious to me at first. I scaled the values using StandardScaler() and then verified that it worked as expected by checking for standard deviation values of 1.

Step 2.2: Perform Dimensionality Reduction

On your scaled data, you are now ready to apply dimensionality reduction techniques.

  • Use sklearn's PCA class to apply principal component analysis on the data, thus finding the vectors of maximal variance in the data. To start, you should not set any parameters (so all components are computed) or set a number of components that is at least half the number of features (so there's enough features to see the general trend in variability).
  • Check out the ratio of variance explained by each principal component as well as the cumulative variance explained. Try plotting the cumulative or sequential values using matplotlib's plot() function. Based on what you find, select a value for the number of transformed features you'll retain for the clustering part of the project.
  • Once you've made a choice for the number of components to keep, make sure you re-fit a PCA instance to perform the decided-on transformation.
In [47]:
azdias_scaled.shape
Out[47]:
(779676, 216)
In [48]:
# Apply PCA to the data.
pca = PCA()
pca.fit_transform(azdias_scaled)
Out[48]:
array([[ 4.75244444e+00, -4.21165485e+00, -3.14470336e+00, ...,
         3.07698946e-15, -6.48685625e-18,  9.09953246e-17],
       [-7.12592499e-01, -7.69942165e-01, -2.85266875e+00, ...,
         2.45244527e-15,  3.15882280e-15, -3.54269055e-16],
       [-4.55665433e+00,  1.96154766e+00, -2.12562663e+00, ...,
         6.42007267e-14,  2.69818710e-14, -3.09153788e-18],
       ...,
       [-8.76678079e-01, -4.11513032e+00, -4.13900240e+00, ...,
        -1.22555682e-16,  1.40487125e-16, -1.85647047e-17],
       [ 6.27892860e+00, -4.98353597e+00,  2.88670899e+00, ...,
         2.17685112e-17, -4.64351911e-17,  1.33162051e-17],
       [ 9.85468017e-01,  2.35855516e+00,  1.57357526e+00, ...,
         5.16895295e-17, -4.79932659e-18, -5.88911057e-19]])
In [49]:
# Investigate the variance accounted for by each principal component.

def scree_plot(pca):
    '''
    Creates a scree plot associated with the principal components 

    INPUT: pca - the result of instantiation of PCA in scikit learn

    OUTPUT:
            None
    '''
    num_components = len(pca.explained_variance_ratio_)
    ind = np.arange(num_components)
    vals = pca.explained_variance_ratio_

    ax1 = plt.subplot(111)
    cumvals = np.cumsum(vals)
    ax1.bar(ind, vals)

    ax2 = ax1.twinx()

    ax2.plot(ind, cumvals, color='r')

    ax1.xaxis.set_tick_params(width=0)
    ax1.yaxis.set_tick_params(width=2, length=12)

    ax1.set_xlabel("Principal Component")
    ax1.set_ylabel("Variance Explained (%)")
    ax2.set_ylabel("Total Variance Explained (%)")
    ax1.grid(None)

    plt.title('Explained Variance Per Principal Component')
In [50]:
scree_plot(pca)

We can see from the plot that 80% of the variance is explained by fewer than 100 components. I estimated the cutoff to be approximately 85 components.

In [51]:
# Re-apply PCA to the data while selecting for number of components to retain.

# Approximately 85 components explain 80% of the variance
pca_85 = PCA(n_components=85)
azdias_pca = pca_85.fit_transform(azdias_scaled)
In [52]:
scree_plot(pca_85)

After re-applying PCA with 85 components, I can see that my estimate was quite close - these 85 components explain almost 80% of the variance.

In [53]:
# I borrowed this function from the practice project helper functions
def pca_results(full_dataset, pca):
    '''
    Create a DataFrame of the PCA results
    Includes dimension feature weights and explained variance
    Visualizes the PCA results
    '''

    # Dimension indexing
    dimensions = dimensions = ['Dimension {}'.format(
        i) for i in range(1, len(pca.components_)+1)]

    # PCA components
    components = pd.DataFrame(
        np.round(pca.components_, 4), columns=full_dataset.keys())
    components.index = dimensions

    # PCA explained variance
    ratios = pca.explained_variance_ratio_.reshape(len(pca.components_), 1)
    variance_ratios = pd.DataFrame(
        np.round(ratios, 4), columns=['Explained Variance'])
    variance_ratios.index = dimensions

    # Create a bar plot visualization
    fig, ax = plt.subplots(figsize=(14, 8))

    # Plot the feature weights as a function of the components
    components.plot(ax=ax, kind='bar')
    ax.set_ylabel("Feature Weights")
    ax.set_xticklabels(dimensions, rotation=0)

    # Display the explained variance ratios
    for i, ev in enumerate(pca.explained_variance_ratio_):
        ax.text(i-0.40, ax.get_ylim()[1] + 0.05,
                "Explained Variance\n          %.4f" % (ev))

    # Return a concatenated DataFrame
    return pd.concat([variance_ratios, components], axis=1)
In [54]:
pca_results(azdias_scaled, pca_85)
Out[54]:
Explained Variance ALTERSKATEGORIE_GROB ALTER_HH ANREDE_KZ_1.0 ANREDE_KZ_2.0 ANZ_HAUSHALTE_AKTIV ANZ_HH_TITEL ANZ_PERSONEN ANZ_TITEL ARBEIT BALLRAUM CAMEO_DEUG_2015_1.0 CAMEO_DEUG_2015_2.0 CAMEO_DEUG_2015_3.0 CAMEO_DEUG_2015_4.0 CAMEO_DEUG_2015_5.0 CAMEO_DEUG_2015_6.0 CAMEO_DEUG_2015_7.0 CAMEO_DEUG_2015_8.0 CAMEO_DEUG_2015_9.0 CAMEO_DEU_2015_1A CAMEO_DEU_2015_1B CAMEO_DEU_2015_1C CAMEO_DEU_2015_1D CAMEO_DEU_2015_1E CAMEO_DEU_2015_2A CAMEO_DEU_2015_2B CAMEO_DEU_2015_2C CAMEO_DEU_2015_2D CAMEO_DEU_2015_3A CAMEO_DEU_2015_3B CAMEO_DEU_2015_3C CAMEO_DEU_2015_3D CAMEO_DEU_2015_4A CAMEO_DEU_2015_4B CAMEO_DEU_2015_4C CAMEO_DEU_2015_4D CAMEO_DEU_2015_4E CAMEO_DEU_2015_5A CAMEO_DEU_2015_5B CAMEO_DEU_2015_5C CAMEO_DEU_2015_5D CAMEO_DEU_2015_5E CAMEO_DEU_2015_5F CAMEO_DEU_2015_6A CAMEO_DEU_2015_6B CAMEO_DEU_2015_6C CAMEO_DEU_2015_6D CAMEO_DEU_2015_6E CAMEO_DEU_2015_6F ... MOVEMENT_AVANTGARDE MOVEMENT_MAINSTREAM NATIONALITAET_KZ_1.0 NATIONALITAET_KZ_2.0 NATIONALITAET_KZ_3.0 ONLINE_AFFINITAET ORTSGR_KLS9 OST_WEST_KZ_O OST_WEST_KZ_W PLZ8_ANTG1 PLZ8_ANTG2 PLZ8_ANTG3 PLZ8_ANTG4 PLZ8_BAUMAX PLZ8_GBZ PLZ8_HHZ REGIOTYP RELAT_AB RETOURTYP_BK_S SEMIO_DOM SEMIO_ERL SEMIO_FAM SEMIO_KAEM SEMIO_KRIT SEMIO_KULT SEMIO_LUST SEMIO_MAT SEMIO_PFLICHT SEMIO_RAT SEMIO_REL SEMIO_SOZ SEMIO_TRADV SEMIO_VERT SHOPPER_TYP_0.0 SHOPPER_TYP_1.0 SHOPPER_TYP_2.0 SHOPPER_TYP_3.0 SOHO_KZ_0.0 SOHO_KZ_1.0 VERS_TYP_1.0 VERS_TYP_2.0 WOHNDAUER_2008 WOHNLAGE W_KEIT_KIND_HH ZABEOTYP_1.0 ZABEOTYP_2.0 ZABEOTYP_3.0 ZABEOTYP_4.0 ZABEOTYP_5.0 ZABEOTYP_6.0
Dimension 1 0.0782 -0.0721 0.0091 -0.0113 0.0113 0.1106 0.0255 -0.0924 -0.0060 0.1086 -0.0870 -0.0458 -0.0846 -0.0617 -0.0709 -0.0101 0.0020 0.0351 0.0909 0.1082 -0.0180 -0.0123 -0.0123 -0.0362 -0.0161 -0.0366 -0.0351 -0.0431 -0.0473 -0.0258 -0.0261 -0.0327 -0.0351 -0.0439 -0.0204 -0.0445 -0.0145 -0.0107 0.0029 -0.0143 -0.0129 0.0048 -0.0019 -0.0054 0.0062 -0.0085 0.0011 0.0015 0.0125 0.0032 ... -0.1099 0.1050 -0.0513 0.0441 0.0240 -0.0598 0.1426 0.0472 -0.0460 -0.1738 0.1164 0.1711 0.1665 0.1633 -0.1279 0.0310 0.0570 0.0997 -0.0075 0.0216 -0.0426 0.0428 0.0332 0.0161 0.0366 -0.0483 0.0459 0.0662 0.0563 0.0609 0.0239 0.0531 -0.0364 -0.0176 0.0040 0.0367 -0.0269 0.0025 -0.0025 -0.0244 0.0244 -0.0502 -0.0536 0.0550 -0.0938 -0.0503 -0.0042 0.0299 0.0721 0.0383
Dimension 2 0.0565 0.2311 -0.1793 -0.0388 0.0388 0.0375 0.0224 -0.0647 0.0072 0.0399 -0.0320 0.0037 -0.0184 -0.0168 -0.0307 -0.0051 0.0134 0.0096 0.0312 0.0110 -0.0006 0.0004 0.0021 0.0032 0.0032 -0.0174 -0.0091 -0.0090 -0.0038 -0.0193 -0.0158 -0.0108 0.0032 -0.0257 -0.0110 -0.0168 -0.0020 0.0018 -0.0045 -0.0105 -0.0115 0.0093 0.0030 0.0037 -0.0011 -0.0038 0.0058 0.0071 0.0233 0.0114 ... -0.0014 -0.0089 0.0688 -0.0471 -0.0486 -0.1563 0.0492 0.0182 -0.0159 -0.0477 0.0346 0.0484 0.0453 0.0445 -0.0371 0.0080 0.0035 0.0365 0.1534 0.0272 0.1794 -0.1312 0.0529 0.0719 -0.1603 0.1643 -0.1255 -0.2019 -0.1653 -0.2130 -0.0647 -0.2041 -0.0222 -0.0476 -0.0257 0.0012 0.0677 0.0017 -0.0017 -0.0218 0.0218 0.0548 -0.0314 0.1236 -0.0509 -0.0302 0.1942 -0.1028 -0.0960 0.0205
Dimension 3 0.0369 0.0174 -0.0321 0.3123 -0.3123 0.0219 0.0160 0.0112 0.0163 0.0387 -0.0637 0.0295 0.0120 -0.0215 -0.0355 0.0025 -0.0104 -0.0000 0.0137 0.0237 0.0097 0.0053 0.0103 0.0212 0.0163 0.0013 -0.0041 0.0027 0.0178 -0.0087 -0.0121 -0.0104 -0.0120 -0.0273 -0.0118 -0.0214 -0.0006 -0.0014 0.0006 -0.0091 -0.0131 0.0205 0.0019 0.0022 -0.0006 -0.0140 -0.0008 0.0005 0.0013 0.0000 ... 0.1095 -0.1063 -0.0056 0.0261 -0.0267 -0.0113 0.0827 -0.0066 0.0091 -0.0490 0.0432 0.0561 0.0547 0.0560 -0.0317 0.0235 -0.0337 0.0426 0.0731 -0.2468 -0.1883 0.2363 -0.2797 -0.2397 0.2285 0.0316 0.0811 -0.0187 -0.1374 0.1111 0.2305 -0.0216 0.2876 0.1021 0.0470 -0.0854 -0.0514 -0.0006 0.0006 -0.0111 0.0111 0.0182 -0.0616 0.0559 0.1098 -0.0081 -0.0359 -0.0578 -0.0260 0.0427
Dimension 4 0.0314 -0.0283 0.0559 -0.1272 0.1272 0.0197 0.0282 0.1141 0.0292 0.0645 -0.1412 0.0871 0.0561 -0.0435 -0.0552 0.0157 -0.0276 -0.0053 0.0100 0.0089 0.0328 0.0216 0.0309 0.0589 0.0425 0.0221 -0.0058 0.0176 0.0607 -0.0065 -0.0187 -0.0222 -0.0321 -0.0503 -0.0213 -0.0278 0.0038 -0.0011 0.0073 -0.0158 -0.0183 0.0442 0.0080 0.0058 -0.0014 -0.0329 0.0005 -0.0006 -0.0037 -0.0036 ... 0.2510 -0.2406 -0.0110 0.0053 0.0108 0.0938 0.1824 -0.0425 0.0450 -0.0669 0.0802 0.0986 0.0901 0.0794 -0.0294 0.0657 -0.0836 0.0825 -0.0191 0.1518 0.0533 -0.0910 0.1456 0.0717 -0.0930 0.0050 -0.0259 0.0120 0.0686 -0.0414 -0.0588 0.0333 -0.1050 -0.0500 -0.0403 0.0290 0.0572 -0.0031 0.0031 -0.0214 0.0214 0.0203 -0.1745 -0.0912 0.0312 0.0724 -0.0379 0.0075 -0.0052 -0.0329
Dimension 5 0.0240 0.0497 0.0743 0.0314 -0.0314 0.0393 -0.0022 0.2627 -0.0003 0.0569 0.0118 -0.0616 -0.0597 -0.0049 0.0028 -0.0297 -0.0052 -0.0009 0.0509 0.0647 -0.0308 -0.0200 -0.0197 -0.0367 -0.0244 -0.0116 -0.0054 -0.0184 -0.0645 0.0043 0.0140 -0.0196 0.0031 0.0165 0.0109 -0.0091 -0.0107 -0.0028 -0.0130 0.0022 0.0032 -0.0395 -0.0100 -0.0077 0.0070 -0.0079 -0.0134 -0.0030 0.0129 -0.0017 ... -0.1282 0.1257 -0.0166 0.0259 -0.0082 0.0840 0.0069 0.0870 -0.0855 -0.0680 0.0018 0.0477 0.0627 0.0687 -0.1012 -0.0541 0.1034 0.0313 0.0247 -0.0329 0.0263 -0.0023 -0.0117 -0.0544 0.0118 0.0220 -0.0363 -0.0352 -0.0519 -0.0279 0.0158 -0.0631 0.0300 0.0128 -0.0409 0.0215 0.0115 -0.0052 0.0052 -0.0100 0.0100 0.0858 0.0503 -0.1872 -0.0154 0.0134 0.0202 0.0444 -0.0696 -0.0170
Dimension 6 0.0172 -0.0019 -0.0035 -0.0017 0.0017 -0.0413 0.0067 0.0493 0.0197 -0.0143 0.0113 0.0017 -0.0920 -0.0693 -0.1534 0.0868 0.3517 0.1534 -0.0544 -0.1893 0.0267 -0.0120 -0.0102 -0.0102 0.0016 -0.0536 0.0031 -0.0543 -0.0652 -0.0111 -0.0036 -0.0617 -0.0365 -0.0973 -0.0061 -0.1081 -0.0405 -0.0216 0.0401 0.0153 0.0618 0.0436 0.0123 0.0247 0.0521 0.2925 0.0936 0.0519 0.1208 0.0654 ... -0.0126 0.0146 0.0138 -0.0181 0.0021 0.0148 -0.0304 -0.0084 0.0090 -0.0108 0.0468 0.0076 -0.0228 -0.0275 0.0399 0.0276 -0.0455 -0.0065 -0.0132 -0.0155 -0.0130 0.0050 -0.0217 -0.0245 -0.0094 0.0345 0.0187 -0.0102 -0.0037 0.0025 0.0040 0.0036 0.0095 0.0183 -0.0020 -0.0256 0.0127 -0.0003 0.0003 0.0139 -0.0139 0.0129 0.0021 -0.0025 -0.0124 -0.0286 0.0103 0.0181 0.0024 -0.0117
Dimension 7 0.0156 0.0113 0.0159 0.0067 -0.0067 0.0226 0.0411 0.0395 0.0216 -0.1002 -0.0242 -0.1404 -0.2718 0.1401 0.2500 0.1909 -0.0775 -0.0290 -0.0389 -0.0280 -0.0853 -0.0382 -0.0379 -0.0859 -0.0432 -0.0881 -0.1529 -0.1364 -0.1450 0.0184 0.0213 0.1236 0.0706 0.1522 0.0443 0.1578 0.0750 0.0482 0.0770 0.0799 0.0446 0.1359 0.0498 0.0458 0.0147 -0.0845 -0.0060 0.0137 -0.0337 -0.0195 ... 0.0216 -0.0223 -0.0156 0.0227 -0.0056 -0.0021 0.0071 -0.1890 0.1897 0.0095 0.0600 0.0021 -0.0116 -0.0108 0.0733 0.0846 -0.0372 -0.0083 0.0109 -0.0031 0.0005 0.0041 -0.0180 -0.0114 -0.0139 0.0224 -0.0151 -0.0121 -0.0217 -0.0131 0.0037 -0.0166 0.0038 0.0190 -0.0109 -0.0071 0.0029 -0.0017 0.0017 -0.0383 0.0383 0.0133 -0.0094 -0.0154 -0.0111 -0.0540 0.0203 0.0212 -0.0122 -0.0011
Dimension 8 0.0151 0.0198 0.0439 0.0096 -0.0096 0.0062 0.0292 -0.0505 0.0267 -0.0524 -0.0505 -0.0255 0.0308 -0.1011 -0.0699 0.2954 -0.0229 0.0138 -0.0826 0.0196 0.0053 -0.0058 -0.0022 -0.0349 -0.0136 0.0404 0.0299 0.0020 -0.0009 0.0299 0.0139 -0.0647 -0.1135 -0.0092 -0.0064 -0.0634 -0.0310 -0.0343 0.1503 0.1273 0.1289 0.1432 0.0635 0.0583 0.0466 -0.0040 -0.0177 0.0173 -0.0564 -0.0258 ... -0.0369 0.0320 -0.0214 0.0408 -0.0209 0.0340 0.0365 -0.0777 0.0689 -0.0281 0.0094 0.0141 0.0385 0.0408 -0.0286 -0.0060 -0.0014 -0.0075 0.0657 0.0634 0.0332 -0.0002 0.0476 0.0855 -0.0075 -0.0472 0.0416 0.0068 0.0236 -0.0266 -0.0396 0.0122 0.0022 -0.1224 0.0772 0.0567 -0.0372 -0.0061 0.0061 -0.0098 0.0098 -0.0428 -0.0073 -0.1143 -0.0242 0.0545 -0.0377 0.0385 -0.0957 0.0990
Dimension 9 0.0146 -0.0033 -0.0049 -0.0083 0.0083 0.0670 0.0677 0.0491 0.0519 -0.0850 0.0555 0.0615 0.2062 -0.1811 -0.1037 0.2579 -0.1256 -0.0839 0.0060 0.0521 0.0333 0.0285 0.0349 0.0223 0.0207 0.0804 0.0749 0.1059 0.1275 -0.1095 -0.0645 -0.0738 -0.1120 -0.0297 -0.0429 -0.0743 -0.0356 -0.0387 0.1060 0.1282 0.0971 0.1385 0.0626 0.0589 0.0223 -0.1206 -0.0386 0.0144 -0.0471 -0.0378 ... -0.0487 0.0459 0.0086 -0.0195 0.0126 -0.0320 -0.0909 0.0375 -0.0324 0.0349 -0.0677 -0.0494 -0.0189 0.0009 0.0218 0.0093 -0.0748 -0.0842 -0.0356 -0.0492 -0.0123 -0.0005 -0.0445 -0.0502 -0.0141 0.0373 -0.0240 -0.0227 -0.0176 0.0023 0.0219 -0.0021 -0.0023 0.0651 -0.0289 -0.0475 0.0245 -0.0037 0.0037 -0.0032 0.0032 0.0311 0.0966 0.0625 0.0310 -0.0354 0.0344 -0.0574 0.0624 -0.0511
Dimension 10 0.0144 -0.0094 -0.0356 -0.0259 0.0259 0.0274 0.0517 -0.0376 0.0409 0.1326 0.0203 0.0329 -0.1372 0.1852 -0.0550 0.1443 -0.0162 -0.0904 -0.0001 -0.0497 -0.0040 -0.0104 0.0093 0.0366 0.0369 -0.0850 -0.0398 -0.0474 -0.0893 0.0476 0.0249 0.0615 0.1839 -0.0745 -0.0112 -0.0162 -0.0091 0.0287 0.0668 0.0292 0.0489 0.0972 0.0300 0.0629 0.0117 -0.0807 -0.0304 0.0570 0.0778 0.0277 ... 0.0470 -0.0514 0.0639 -0.0783 0.0024 0.0420 -0.0024 0.3412 -0.3427 -0.0781 -0.0756 0.0239 0.0613 0.0875 -0.1950 -0.1821 -0.0880 0.0057 -0.0380 -0.0146 -0.0019 -0.0023 0.0019 -0.0085 -0.0115 0.0030 0.0550 -0.0075 0.0329 0.0090 0.0004 0.0322 0.0122 -0.0281 0.0159 -0.0591 0.0676 -0.0076 0.0076 0.1238 -0.1238 -0.0232 0.0260 -0.0004 0.0016 0.0499 -0.0274 -0.0028 0.0163 -0.0047
Dimension 11 0.0134 -0.0007 0.0535 -0.0067 0.0067 0.1023 0.1036 0.0172 0.1018 -0.0840 0.0096 0.0370 0.0508 0.0535 0.0418 -0.2391 -0.0840 0.1475 -0.0093 -0.0099 0.0184 0.0127 0.0337 0.0007 0.0267 0.0025 0.0130 0.0304 0.0425 -0.0064 0.0113 0.0707 0.0095 0.0077 0.0098 0.0423 0.0133 0.0012 -0.1021 -0.1300 -0.1226 -0.0733 -0.0622 -0.0791 -0.0532 -0.0525 -0.0013 -0.0695 -0.0158 -0.0212 ... -0.0069 0.0028 0.0118 -0.0081 -0.0084 -0.0094 -0.0645 0.0629 -0.0570 0.0084 -0.0717 -0.0413 0.0086 0.0373 0.0149 0.0270 -0.0939 -0.1031 0.0168 0.0269 0.0136 -0.0012 0.0003 0.0221 -0.0177 0.0087 0.0183 -0.0025 0.0151 -0.0134 -0.0096 0.0143 -0.0155 -0.0457 0.0476 0.0086 -0.0214 -0.0138 0.0138 -0.0308 0.0308 0.0086 0.0913 -0.0272 0.0106 0.0168 -0.0076 -0.0234 -0.0251 0.0500
Dimension 12 0.0124 0.0150 -0.0630 -0.0331 0.0331 0.1229 0.0966 -0.0073 0.0552 -0.1382 -0.0243 0.1279 -0.0330 0.0913 -0.0545 -0.0739 0.0453 -0.0944 -0.1340 0.1448 0.0746 0.0107 0.0180 0.0916 0.0605 0.0421 0.0302 -0.0462 -0.0612 0.0974 0.0697 -0.0218 0.0747 0.0452 0.0207 -0.1129 -0.0397 0.0165 -0.0267 -0.0190 -0.0105 -0.0711 -0.0366 -0.0019 -0.0162 0.0525 -0.0347 0.0136 0.0371 0.0200 ... -0.0537 0.0385 -0.0243 0.0238 0.0072 0.0294 -0.0088 -0.1563 0.1381 0.0173 -0.0197 -0.0027 0.0396 -0.0025 0.0573 0.0962 0.0332 -0.0723 -0.0174 -0.0362 0.0019 0.0068 0.0130 -0.0061 -0.0181 0.0431 0.0839 0.0021 0.0463 0.0146 -0.0189 0.0354 0.0137 -0.0268 0.0032 -0.0879 0.1101 -0.0171 0.0171 0.2033 -0.2033 -0.0372 0.0031 0.0440 0.0316 0.0488 -0.0137 -0.0320 0.0342 -0.0391
Dimension 13 0.0121 0.0074 -0.0832 -0.0208 0.0208 -0.0588 -0.0269 -0.0060 -0.0081 -0.0117 -0.0349 -0.0826 0.1143 -0.0002 -0.0069 -0.0198 -0.1594 0.1512 0.1690 -0.2061 -0.0519 0.0094 0.0096 -0.0762 -0.0417 -0.0112 -0.0061 0.0820 0.1201 0.0020 -0.0182 0.0662 -0.0593 -0.0755 -0.0371 0.0656 0.0305 -0.0250 0.0142 -0.0574 -0.0399 0.0413 0.0120 -0.0303 -0.0276 -0.1493 0.0118 -0.0509 -0.0538 -0.0348 ... -0.0666 0.0626 -0.0066 0.0052 0.0038 0.0485 0.0081 -0.0338 0.0211 -0.0348 0.0692 0.0420 0.0094 -0.0002 0.0265 0.0381 -0.0456 0.0009 0.0189 -0.0065 0.0009 0.0213 0.0118 0.0030 0.0045 0.0093 0.1365 0.0189 0.0666 0.0287 -0.0277 0.0616 0.0225 -0.0547 0.0257 -0.0295 0.0494 -0.0053 0.0053 0.2291 -0.2291 -0.0185 -0.0264 -0.0382 -0.0156 0.0330 -0.0288 0.0304 -0.0455 0.0470
Dimension 14 0.0118 0.0473 0.0144 -0.0346 0.0346 -0.0178 -0.0439 -0.0011 -0.0433 -0.0120 0.0804 -0.1318 -0.0618 -0.1562 0.0851 0.0214 -0.1329 0.2818 -0.0550 0.1048 -0.0836 -0.0542 -0.0561 -0.0444 -0.0555 0.0497 -0.0261 -0.0314 -0.0821 -0.0317 -0.0234 -0.1251 -0.0853 0.1491 0.0149 -0.0081 -0.0097 0.0028 0.0521 0.0688 -0.0017 -0.0532 -0.0151 -0.0054 0.0023 -0.0870 -0.0612 -0.0437 -0.0607 -0.0288 ... 0.0928 -0.1016 0.0613 -0.0559 -0.0242 -0.0198 -0.0516 0.0347 -0.0482 -0.0296 -0.0202 0.0028 0.0247 0.0414 -0.0859 -0.0932 0.0482 -0.0091 -0.0507 -0.0498 0.0467 -0.0038 -0.0042 -0.0381 -0.0198 0.0477 0.0669 -0.0163 0.0177 -0.0068 -0.0165 -0.0112 0.0134 -0.0230 0.0034 -0.0588 0.0766 0.0104 -0.0104 0.2306 -0.2306 0.0083 0.0766 0.0418 0.0251 -0.0119 0.0115 -0.0518 0.0595 -0.0274
Dimension 15 0.0116 0.0367 -0.0163 0.0164 -0.0164 0.0678 0.0121 -0.0138 -0.0273 -0.0379 0.0783 -0.0175 0.0140 -0.1176 0.0646 -0.0605 0.0779 -0.1075 0.0049 0.1120 0.0134 -0.0147 -0.0149 -0.0167 -0.0128 0.0720 0.0074 -0.0238 -0.0112 -0.0171 -0.0024 -0.0838 -0.0855 0.1232 0.0194 -0.0161 -0.0077 -0.0031 -0.0472 0.0202 0.0001 -0.0558 -0.0318 -0.0304 -0.0121 0.0843 0.0007 -0.0047 0.0393 0.0080 ... 0.0653 -0.0659 -0.0316 0.0421 -0.0059 0.0094 -0.0856 0.0699 -0.0591 0.0054 -0.0281 -0.0049 -0.0011 -0.0165 0.0559 0.0726 -0.0553 -0.0552 0.0386 -0.0187 0.0251 0.0163 -0.0347 -0.0142 0.0079 0.0075 0.0364 -0.0201 -0.0251 -0.0142 0.0143 -0.0070 0.0210 -0.0303 0.0128 0.0223 -0.0109 0.0011 -0.0011 0.0643 -0.0643 0.0516 0.0846 -0.1349 -0.0459 -0.0089 -0.0301 0.0901 -0.1248 0.1107
Dimension 16 0.0113 0.0031 -0.0204 0.0351 -0.0351 0.0399 0.0353 -0.0296 0.0353 0.0278 -0.0248 -0.0566 0.0194 -0.1194 0.1411 0.0045 0.0123 0.1263 -0.1026 -0.0100 -0.0382 -0.0141 -0.0068 -0.0355 -0.0194 0.0246 -0.0031 0.0130 0.0059 -0.0516 -0.0320 -0.0615 -0.0774 0.0975 0.0211 0.0897 0.0324 0.0145 -0.0043 0.0236 -0.0130 0.0061 0.0024 -0.0076 0.0004 -0.0033 0.0175 -0.0095 0.0225 0.0032 ... 0.0194 -0.0099 0.0781 -0.0790 -0.0200 0.0958 0.0412 0.0585 -0.0437 0.0200 -0.0803 -0.0361 0.0086 0.0292 -0.0762 -0.0840 0.0390 0.0044 -0.0710 -0.0197 -0.0062 -0.0318 -0.0285 0.0062 -0.0182 -0.0044 -0.2057 -0.0546 -0.1049 -0.0466 0.0331 -0.0895 -0.0040 0.1202 -0.0671 -0.0138 -0.0160 -0.0133 0.0133 -0.2614 0.2614 -0.0577 -0.0083 0.0398 -0.0097 0.0077 0.0039 0.0841 0.0318 -0.1618
Dimension 17 0.0110 -0.0183 -0.0397 -0.0323 0.0323 -0.0097 0.0082 -0.0039 0.0447 0.0663 -0.0133 -0.1474 0.0507 -0.2117 0.2499 -0.0426 0.2405 -0.2339 -0.0257 -0.0033 -0.0394 -0.0271 -0.0151 -0.1415 -0.0742 -0.0224 0.0320 0.0311 0.0447 -0.0452 -0.0509 -0.0680 -0.2073 0.0912 0.0784 0.2019 0.0864 0.0102 -0.0682 -0.0309 -0.0145 0.0420 0.0085 -0.0485 0.0154 0.2235 0.1193 0.0060 0.0346 0.0170 ... 0.0141 -0.0159 -0.0178 0.0096 0.0162 -0.0388 0.0429 0.0297 -0.0415 -0.0219 0.0067 0.0078 0.0075 0.0219 -0.1136 -0.1339 -0.0223 0.0628 0.0006 0.0188 -0.0067 0.0127 0.0297 -0.0101 0.0221 -0.0272 0.0896 0.0529 0.0754 0.0460 -0.0264 0.0613 -0.0114 -0.0131 -0.0153 0.0130 0.0146 -0.0177 0.0177 0.1762 -0.1762 0.0075 -0.0309 0.0443 0.0142 0.0005 -0.0062 -0.0449 0.0220 0.0368
Dimension 18 0.0108 -0.1071 -0.0976 -0.0306 0.0306 -0.0555 -0.0280 0.0225 0.0456 0.0263 0.0223 0.1116 -0.1083 -0.0021 -0.0042 0.0266 -0.0323 0.0577 -0.0596 0.0836 0.0360 0.0211 0.0219 0.0952 0.0551 -0.0156 -0.0525 -0.0537 -0.0761 -0.0619 -0.0451 -0.0161 0.0688 0.0272 -0.0188 -0.0206 -0.0105 0.0139 0.0137 0.0402 0.0019 -0.0113 0.0002 0.0249 0.0161 -0.0318 -0.0343 0.0152 -0.0078 0.0019 ... 0.0120 0.0051 -0.1445 0.1168 0.0777 -0.0818 -0.0217 0.0188 -0.0049 0.0245 0.0026 -0.0245 -0.0456 -0.0255 0.0562 0.0343 -0.0101 0.0080 0.0620 0.0985 -0.0466 0.0292 0.0503 0.0510 0.0742 -0.0832 0.1082 0.1439 0.1570 0.1092 -0.0294 0.1503 -0.0748 -0.0285 0.0374 0.1403 -0.1607 -0.0116 0.0116 -0.0293 0.0293 0.0646 0.0252 0.0966 0.0289 0.0206 -0.0506 -0.0696 -0.0262 0.1676
Dimension 19 0.0104 -0.0339 -0.0282 -0.0066 0.0066 0.1473 0.0579 0.0105 -0.1073 -0.0013 -0.1185 -0.1018 0.1424 0.0477 0.0272 -0.0016 0.0568 0.1470 -0.3981 0.1198 -0.0787 -0.0097 -0.0226 -0.0508 -0.0450 0.0329 0.0079 0.0813 0.1256 -0.0279 -0.0404 0.0666 0.0408 -0.0195 -0.0369 0.0522 0.0321 0.0156 -0.0081 -0.0161 -0.0487 0.0449 0.0187 0.0072 0.0010 -0.0376 0.0657 0.0303 0.1037 0.0326 ... -0.0468 0.0394 -0.0747 0.0582 0.0431 -0.0252 0.0700 0.0646 -0.0603 0.0175 -0.1022 -0.0221 0.0453 0.0268 -0.0168 0.0252 -0.0519 -0.0492 0.0470 0.0218 -0.0121 0.0167 0.0195 0.0062 0.0134 -0.0182 0.0353 0.0302 0.0478 0.0329 0.0128 0.0594 -0.0051 -0.0281 0.0524 -0.0435 0.0118 0.0633 -0.0633 0.0018 -0.0018 0.0216 -0.0332 -0.0103 0.0033 -0.0169 -0.0185 0.0085 -0.0282 0.0558
Dimension 20 0.0102 -0.0145 -0.0137 0.0000 -0.0000 -0.0453 0.0285 -0.0068 0.0601 0.0469 -0.0611 0.3572 -0.1111 -0.2728 0.2383 -0.0515 -0.0484 0.0488 0.0150 -0.0923 0.1714 0.1123 0.1168 0.2051 0.1648 0.0115 -0.0578 -0.0665 -0.0840 -0.1235 -0.1078 -0.2100 -0.0880 0.1994 0.0289 0.1106 0.0478 0.0762 -0.0329 0.0135 -0.0661 -0.0153 -0.0234 0.0057 -0.0229 -0.0998 -0.0175 0.0203 0.0632 0.0356 ... -0.0703 0.0677 -0.0186 0.0141 0.0114 0.0052 0.0772 -0.0265 0.0157 -0.0038 0.0299 0.0123 -0.0009 0.0078 -0.0925 -0.1173 -0.0447 0.0804 0.0179 0.0176 -0.0062 0.0005 0.0095 0.0107 0.0067 -0.0192 0.0295 0.0046 0.0197 0.0072 0.0033 0.0247 0.0085 -0.0224 0.0315 -0.0350 0.0209 0.0027 -0.0027 -0.0011 0.0011 0.0023 -0.0806 -0.0409 -0.0208 0.0013 -0.0031 0.0325 -0.0284 0.0116
Dimension 21 0.0099 0.0059 0.0178 -0.0057 0.0057 -0.0970 -0.0421 0.0311 0.0074 0.0446 -0.0407 -0.0257 0.0546 0.1082 -0.0806 -0.0599 -0.0421 -0.0622 -0.1307 0.2152 0.0562 -0.0024 -0.0030 -0.0805 -0.0209 0.0029 0.0980 0.0064 0.0088 0.0909 0.0701 0.0634 0.0186 -0.0527 0.0292 -0.0599 -0.0207 -0.0413 -0.0135 -0.0482 -0.0037 -0.0099 -0.0346 -0.0550 -0.0081 0.0541 -0.0415 -0.0556 -0.0950 -0.0436 ... 0.0061 -0.0097 -0.0370 0.0400 0.0059 0.0008 0.0387 -0.0730 0.0601 -0.0430 0.0795 0.0266 -0.0052 0.0398 -0.1720 -0.2216 0.0933 0.0920 0.0224 -0.0021 0.0153 -0.0108 0.0104 0.0462 -0.0171 0.0143 -0.0006 -0.0042 -0.0040 -0.0148 -0.0268 -0.0217 -0.0048 -0.0314 0.0495 0.0115 -0.0388 -0.0163 0.0163 -0.0646 0.0646 0.0043 0.0018 0.0260 -0.0307 0.0224 0.0349 -0.0316 0.0209 -0.0094
Dimension 22 0.0096 0.0224 -0.0365 0.0153 -0.0153 -0.0264 -0.0037 -0.0882 0.0276 0.0119 -0.0054 0.0877 -0.0464 0.0465 -0.0258 -0.0116 -0.0411 0.0339 -0.0762 0.0793 0.0751 0.0348 0.0345 0.0244 0.0202 -0.0880 0.0156 -0.0150 -0.0135 0.0031 0.0197 0.0539 0.0063 -0.0728 0.0201 0.0188 0.0009 -0.0102 -0.0137 -0.0401 0.0483 -0.0069 -0.0018 -0.0143 -0.0049 0.0148 -0.0141 -0.0303 -0.0731 -0.0296 ... 0.0094 -0.0091 -0.0220 0.0137 0.0174 0.0173 0.0124 -0.0392 0.0407 0.0224 -0.0013 -0.0283 -0.0321 -0.0105 -0.0341 -0.0764 0.0106 0.0304 0.0013 -0.0253 -0.0037 0.0038 -0.0228 -0.0233 0.0085 0.0229 -0.0235 -0.0110 -0.0236 -0.0010 -0.0000 -0.0190 0.0094 0.0456 -0.0466 0.0123 -0.0010 0.1021 -0.1021 0.0160 -0.0160 -0.0252 -0.0017 -0.0588 0.0021 -0.1060 -0.0050 0.0970 -0.0515 -0.0125
Dimension 23 0.0094 0.0097 -0.0108 0.0095 -0.0095 -0.0477 -0.0191 -0.0162 0.0323 0.0535 -0.0005 -0.0268 0.0245 0.0181 -0.0294 0.0003 0.0158 0.0750 -0.1116 0.0462 -0.0336 -0.0022 0.0020 -0.0150 0.0016 0.0121 -0.0262 0.0158 0.0348 -0.0188 -0.0213 0.0190 0.0292 -0.0217 -0.0387 -0.0055 0.0027 -0.0055 -0.0143 0.0062 -0.0091 0.0046 0.0099 0.0117 0.0038 -0.0208 0.0262 0.0246 0.0204 0.0219 ... -0.0086 0.0073 0.0358 -0.0283 -0.0200 0.0012 0.0223 0.0064 -0.0081 0.0048 0.0289 0.0122 -0.0176 -0.0318 0.0366 0.0289 0.0534 0.0358 0.0000 -0.0103 0.0055 0.0043 -0.0028 -0.0085 0.0122 0.0077 0.0105 -0.0013 -0.0053 0.0036 0.0038 -0.0103 0.0147 0.0019 0.0020 0.0014 -0.0053 -0.6454 0.6454 0.0199 -0.0199 0.0109 -0.0394 -0.0107 -0.0485 0.0952 -0.0004 0.0072 -0.0147 -0.0000
Dimension 24 0.0091 0.0508 0.0729 0.0277 -0.0277 -0.0063 -0.0155 -0.0011 -0.0391 -0.0404 0.0189 0.1740 -0.1174 -0.0506 0.1017 -0.0034 -0.0377 -0.0686 -0.0383 0.0680 0.1594 0.0580 0.0672 0.0534 0.0284 -0.0676 -0.0175 -0.0601 -0.0760 0.0855 0.0091 0.0035 -0.1334 0.0198 0.0639 0.0836 0.0434 -0.0097 0.0325 -0.0512 0.0179 0.0246 -0.0125 -0.0482 -0.0113 0.0364 -0.0242 -0.0586 -0.0561 -0.0585 ... -0.0139 0.0113 0.1692 -0.1310 -0.0988 0.0248 -0.0312 0.1125 -0.1185 -0.0901 0.0450 0.0907 0.0863 0.0464 0.0980 0.2029 -0.1764 -0.0798 -0.0173 -0.0081 0.0288 0.0005 -0.0284 0.0211 -0.0554 -0.0072 0.0116 -0.0910 -0.0626 -0.0791 -0.0009 -0.0753 0.0430 -0.0855 0.0570 -0.0212 0.0332 -0.0753 0.0753 -0.0044 0.0044 -0.1024 0.0094 -0.0212 -0.0210 0.1004 0.0657 -0.1433 0.1151 -0.0586
Dimension 25 0.0091 0.0387 0.0119 0.0072 -0.0072 -0.1070 -0.0240 0.0166 0.1360 0.0901 0.0383 0.1604 -0.1151 -0.0158 -0.0043 0.0383 0.0011 0.1580 -0.2632 0.1461 0.0974 0.0826 0.0917 0.0440 0.0528 -0.1387 -0.0829 -0.0148 -0.0182 -0.0163 -0.0114 0.0530 -0.0630 -0.1263 -0.0036 0.0937 0.0397 -0.0269 -0.0034 -0.0299 0.0245 0.0600 0.0480 -0.0066 0.0005 0.0117 0.0506 -0.0105 -0.0478 -0.0220 ... -0.0124 0.0114 0.0569 -0.0499 -0.0251 0.0050 -0.0001 0.0624 -0.0613 0.0003 0.0591 0.0207 -0.0450 -0.0693 0.1021 0.0859 0.0290 0.0385 -0.0203 -0.0244 0.0225 0.0040 -0.0141 -0.0387 0.0059 0.0225 0.0289 -0.0224 -0.0120 -0.0078 -0.0038 -0.0346 0.0173 0.0090 -0.0176 0.0074 0.0039 0.1528 -0.1528 0.0884 -0.0884 0.0156 -0.0380 -0.0236 -0.0323 -0.0205 0.0185 0.0249 0.0079 -0.0221
Dimension 26 0.0089 -0.0269 -0.0237 -0.0181 0.0181 0.1594 0.0674 0.0175 -0.0667 -0.1029 0.0114 0.1883 -0.1474 -0.0319 0.0472 0.0447 -0.0645 0.0333 0.0489 -0.0329 0.1494 0.0698 0.0679 0.0864 0.0188 -0.1875 0.0226 -0.0413 -0.0873 0.0193 0.0731 0.0236 -0.1175 -0.1155 0.0997 0.1156 0.0235 -0.0181 0.0340 -0.0524 0.1000 0.0057 0.0274 -0.0080 -0.0001 0.0400 -0.0387 -0.0556 -0.1137 -0.0732 ... 0.0102 -0.0112 -0.1525 0.1211 0.0850 -0.0424 -0.0548 -0.0600 0.0696 0.0739 -0.1355 -0.1139 -0.0313 -0.0031 -0.1197 -0.1896 -0.0694 -0.0578 0.0138 -0.0041 -0.0218 0.0086 -0.0115 -0.0102 -0.0005 -0.0015 -0.0206 0.0328 0.0258 0.0282 0.0126 0.0438 -0.0351 0.0605 -0.0440 -0.0130 0.0092 -0.1658 0.1658 -0.0276 0.0276 0.0587 0.0825 -0.0046 0.0104 -0.0405 -0.0286 0.0493 -0.0418 0.0327
Dimension 27 0.0083 -0.0366 -0.0474 -0.0349 0.0349 -0.0650 -0.0341 -0.0235 -0.0173 0.0863 -0.0054 -0.0445 -0.0007 -0.0239 0.0512 -0.0084 0.0093 -0.1058 0.0321 0.0835 -0.0050 -0.0231 -0.0146 -0.0367 -0.0189 -0.0110 0.0064 -0.0142 0.0121 -0.0378 -0.0257 -0.0077 0.0044 0.0396 0.0138 0.0202 0.0253 0.0060 0.0296 -0.0251 -0.0346 0.0266 -0.0143 -0.0234 0.0180 0.0328 0.0009 -0.0309 -0.0251 -0.0094 ... -0.0016 0.0125 -0.2058 0.1264 0.1657 -0.0007 0.0334 0.1697 -0.1411 -0.0871 0.0567 0.0845 0.0668 0.0947 0.1438 0.2750 -0.1234 0.0153 -0.0336 0.0133 -0.0411 0.0008 -0.0028 -0.0264 -0.0118 0.0329 -0.0342 0.0128 0.0294 0.0318 -0.0039 0.0615 -0.0504 0.1212 -0.0407 -0.0557 -0.0026 -0.0435 0.0435 -0.0627 0.0627 0.0361 0.0011 0.0240 0.0551 -0.0578 -0.0330 0.0637 -0.0217 -0.0479
Dimension 28 0.0081 0.0383 -0.0319 0.0195 -0.0195 0.0102 0.0451 -0.0322 0.0611 -0.0018 0.1048 -0.0350 -0.0443 -0.0620 -0.0286 -0.0145 0.0276 0.0698 0.0260 -0.0042 -0.0560 -0.0133 0.0075 -0.0041 0.0009 -0.0288 -0.0601 0.0126 -0.0171 0.0256 -0.0238 -0.0515 -0.0467 -0.0362 -0.0311 0.0095 -0.0052 -0.0104 -0.0232 -0.0182 -0.0009 0.0069 0.0069 -0.0007 -0.0080 -0.0027 0.0444 0.0128 0.0114 0.0252 ... 0.0402 -0.0572 -0.4461 0.3750 0.2197 -0.0364 -0.0743 0.0096 -0.0377 -0.0363 0.0453 0.0339 0.0142 -0.0388 -0.0002 -0.0102 -0.0071 0.0138 -0.0081 -0.0190 0.0417 0.0057 -0.0224 0.0884 -0.0387 -0.0065 0.0015 -0.0610 -0.0617 -0.0601 0.0177 -0.0521 0.0328 -0.1593 0.2456 -0.1655 0.0393 0.0109 -0.0109 -0.1290 0.1290 -0.1154 0.0231 -0.0163 -0.0963 0.0182 0.0741 -0.0022 0.0489 -0.0638
Dimension 29 0.0079 -0.0303 -0.0709 -0.0104 0.0104 0.1232 0.1323 -0.0180 0.0557 0.0686 0.0061 -0.0587 -0.0209 -0.1812 0.0954 0.0071 0.0309 -0.0243 0.0397 0.0761 -0.0725 -0.0214 -0.0371 0.0140 -0.0164 -0.1118 0.0144 0.0433 -0.0038 -0.0432 -0.0409 -0.1834 -0.0505 -0.1049 0.0567 0.1506 0.0544 0.0702 0.0478 -0.0989 0.0474 -0.0221 0.0140 0.0535 0.0233 0.0063 0.0013 0.0438 0.0114 0.0143 ... 0.0241 -0.0321 0.1992 -0.1603 -0.1080 -0.0030 0.0234 -0.0237 0.0282 0.0205 -0.0215 -0.0108 0.0033 -0.0194 0.1287 0.1768 0.2622 0.0426 -0.0018 -0.0101 0.0166 0.0114 0.0336 0.0409 0.0405 0.0201 -0.0018 0.0638 0.0325 0.0413 0.0189 0.0302 -0.0149 -0.0346 0.0759 -0.0117 -0.0411 0.0183 -0.0183 -0.0748 0.0748 0.0326 0.0111 0.0429 -0.0383 0.0540 -0.0684 0.0759 -0.0401 0.0520
Dimension 30 0.0078 -0.0837 -0.0862 -0.0219 0.0219 0.0705 0.1692 -0.0029 0.2736 0.0361 0.0223 -0.0555 0.0031 0.0808 -0.0196 0.0321 -0.1102 0.1403 0.0458 -0.1009 0.0695 -0.0448 0.0070 -0.1299 -0.0140 0.0809 0.0641 -0.0529 -0.0493 0.1926 0.1088 0.0090 -0.0441 0.0786 0.0536 -0.0907 -0.0169 -0.0574 -0.0425 0.0342 0.0533 0.0520 0.0068 -0.0533 -0.0965 0.0514 -0.0908 -0.1114 -0.1017 -0.0674 ... 0.0271 -0.0301 0.0750 -0.0943 0.0062 -0.0642 0.0183 0.0661 -0.0535 -0.0320 -0.0151 0.0344 0.0493 0.0099 -0.0064 0.0388 -0.0156 0.0176 0.0385 0.0179 -0.0543 0.0213 0.0115 0.0083 0.0092 -0.0790 0.0330 0.0470 0.0833 0.0600 -0.0104 0.1032 -0.0278 0.0644 0.0266 -0.0282 -0.0554 0.0221 -0.0221 -0.1268 0.1268 0.0872 -0.0465 0.0526 0.0348 0.1149 -0.0459 -0.0858 -0.0276 0.1121
Dimension 31 0.0075 -0.0208 -0.0097 -0.0163 0.0163 0.0337 0.1290 -0.0163 0.1344 -0.1190 0.1271 -0.0355 -0.0730 -0.0089 -0.1170 -0.0603 0.1396 -0.0722 0.0318 0.1528 -0.1276 -0.0004 0.0374 0.0139 0.0372 -0.0243 -0.1673 0.0126 0.0096 -0.1185 -0.0333 0.0917 -0.0235 -0.0220 -0.1405 -0.0463 -0.0494 -0.0498 -0.0661 0.0081 -0.1219 0.0599 -0.0057 -0.0308 0.0435 0.0152 0.1780 0.0262 0.0636 0.0521 ... 0.0113 -0.0138 0.2100 -0.1645 -0.1201 -0.0099 -0.1377 -0.1097 0.1119 -0.0460 0.0917 0.0151 -0.0063 0.0244 -0.1085 -0.1470 -0.2170 -0.0351 -0.0191 0.0257 -0.0156 0.0131 -0.0170 0.0241 -0.0274 0.0098 0.0759 0.0036 0.0513 0.0095 -0.0246 0.0714 -0.0350 -0.0134 0.0766 0.0061 -0.0783 -0.0016 0.0016 -0.1237 0.1237 -0.0055 0.1004 -0.0200 0.0642 0.0301 -0.0575 -0.0773 0.0458 0.0623
Dimension 32 0.0073 0.0107 0.0805 0.0114 -0.0114 0.1248 0.2317 0.0216 0.2925 0.0326 -0.0278 -0.0221 -0.0372 0.0100 -0.0582 -0.0104 0.0497 -0.0219 0.0425 0.0303 -0.0621 -0.0007 0.0432 -0.0281 0.0362 0.0078 -0.0697 0.0038 -0.0162 -0.0156 -0.0210 0.0511 -0.0174 -0.0338 -0.0714 -0.0004 -0.0209 -0.0377 -0.0017 0.0087 -0.0511 0.0179 0.0044 -0.0062 0.0248 0.0189 0.0560 -0.0045 0.0119 0.0113 ... 0.0420 -0.0363 -0.1656 0.1413 0.0786 -0.0233 0.0316 -0.0468 0.0473 0.0267 -0.0397 -0.0269 0.0024 -0.0095 0.0259 0.0417 0.0640 0.0500 -0.0108 -0.0095 -0.0121 -0.0286 -0.0062 -0.0663 0.0214 -0.0205 -0.0877 0.0036 -0.0582 -0.0195 0.0065 -0.1046 0.0135 0.0626 -0.2889 0.1317 0.1260 -0.0183 0.0183 0.2120 -0.2120 0.0094 -0.0027 -0.0276 -0.0075 -0.0474 0.1267 -0.0194 0.0120 -0.1521
Dimension 33 0.0072 -0.0078 0.0158 0.0068 -0.0068 -0.0331 0.0429 0.0172 0.1486 -0.0418 0.0163 -0.1607 0.1430 -0.0748 0.1659 -0.0074 -0.0327 -0.0622 -0.0597 0.0288 -0.0937 -0.1469 -0.0927 -0.0595 0.0233 -0.0415 0.1299 0.0319 0.1278 0.0235 -0.0138 -0.1828 0.0619 -0.0480 0.1111 0.1510 0.0561 0.1489 0.0892 -0.1329 0.0193 -0.0115 -0.0343 0.0536 0.0710 -0.0627 -0.1111 0.0560 0.0464 0.0255 ... -0.0268 0.0278 -0.0796 0.0565 0.0536 -0.0228 -0.0359 0.0108 -0.0111 0.0195 -0.0002 -0.0196 -0.0374 -0.0323 -0.0168 -0.0706 -0.1555 -0.0478 0.0379 0.0122 -0.0179 0.0054 -0.0298 0.0101 -0.0310 -0.0257 0.0732 -0.0419 0.0207 -0.0164 -0.0221 0.0121 0.0035 -0.0218 0.0510 -0.0384 0.0027 0.0058 -0.0058 -0.0284 0.0284 0.0028 -0.0159 -0.0332 0.0278 0.0483 0.0472 -0.1488 0.0365 0.0398
Dimension 34 0.0069 0.0742 -0.0085 0.0175 -0.0175 -0.0102 0.0565 0.0036 0.2439 -0.0304 -0.0792 0.0385 0.0548 0.0788 0.0072 0.0033 0.0031 -0.1377 0.0039 -0.0175 0.0310 0.0168 0.0755 -0.0301 0.0174 0.0314 0.0058 0.0225 0.0414 -0.0249 -0.0103 0.0965 0.0428 0.0422 -0.0244 -0.0017 0.0011 -0.0386 0.0697 0.0060 -0.0273 -0.0156 -0.0043 -0.0409 0.0656 -0.0406 0.0072 -0.0158 0.0374 0.0076 ... 0.0054 0.0062 -0.0043 0.0365 -0.0433 0.0941 0.0301 0.0498 -0.0300 0.0434 -0.0856 -0.0372 -0.0084 0.0081 -0.0031 -0.0048 0.1068 -0.0686 -0.0148 -0.0309 0.0612 0.0041 0.0124 0.0333 -0.0029 0.0877 -0.0646 -0.0379 -0.0742 -0.0363 0.0418 -0.0272 0.0262 -0.0757 0.1262 -0.0678 -0.0030 -0.0012 0.0012 -0.0133 0.0133 -0.0766 0.0339 0.0214 -0.1312 -0.0002 -0.1274 0.2965 -0.0926 0.0261
Dimension 35 0.0067 -0.0017 -0.0707 0.0064 -0.0064 0.0376 0.0795 -0.0336 -0.0158 0.0455 0.0734 -0.0978 0.0694 -0.0227 0.0030 0.0028 -0.0985 0.0701 0.0051 0.0632 0.0127 -0.0799 -0.0931 -0.0729 -0.0058 -0.0497 0.1480 -0.0280 0.0558 -0.0078 -0.0062 -0.1021 0.0750 -0.0305 0.0740 -0.0156 -0.0101 0.0496 -0.0170 -0.0565 0.0396 0.0298 -0.0235 0.0321 -0.0970 0.0217 -0.1507 -0.0264 -0.0396 -0.0243 ... 0.0233 -0.0170 0.0610 -0.0445 -0.0394 0.0657 -0.0011 -0.0493 0.0617 0.0355 0.0315 -0.0302 -0.0602 -0.0572 0.0240 -0.0308 -0.1958 0.1076 -0.0235 0.0459 -0.0202 -0.0035 -0.0170 -0.0333 0.0011 -0.0837 -0.0733 0.0044 -0.0362 -0.0136 0.0058 -0.0037 -0.0004 0.0836 -0.2057 0.0637 0.0870 -0.0168 0.0168 0.0313 -0.0313 -0.2041 -0.0658 -0.0701 -0.0600 -0.0905 -0.0345 0.2097 -0.0958 -0.0198
Dimension 36 0.0066 0.0555 0.0581 0.0073 -0.0073 0.0283 0.1130 -0.0095 0.1140 0.0863 0.0065 -0.0756 0.0341 0.0166 0.0066 0.0299 -0.0727 0.0532 0.0264 -0.0213 0.0230 -0.0741 -0.0326 -0.0768 -0.0175 0.0098 0.1094 -0.0495 0.0083 -0.0856 0.0004 -0.0136 0.0871 0.0289 0.0577 -0.0561 0.0224 0.0172 -0.1002 0.0156 0.0602 0.0686 -0.0091 0.0383 -0.1042 0.0772 -0.0931 -0.0542 -0.0895 -0.0622 ... -0.0180 0.0225 0.0214 0.0080 -0.0464 -0.0199 0.0315 0.0144 -0.0146 0.0271 0.0205 -0.0353 -0.0563 -0.0121 0.0388 0.0153 -0.0421 0.0836 -0.0589 0.0306 0.0617 0.0090 0.0077 0.0213 0.0032 0.1316 0.0969 -0.0280 -0.0070 -0.0160 0.0141 -0.0182 -0.0030 -0.1498 0.2560 -0.0572 -0.0916 -0.0089 0.0089 0.0241 -0.0241 0.1100 -0.0274 -0.0148 -0.0105 -0.0381 0.0372 -0.0844 0.1687 -0.0741
Dimension 37 0.0064 -0.0377 -0.1249 0.0084 -0.0084 0.0586 0.0161 -0.0908 -0.0102 0.1404 -0.0615 0.0212 -0.0300 0.0350 -0.0363 0.0013 0.0169 -0.0724 0.0304 0.0079 -0.0012 0.0359 0.0088 0.0234 -0.0187 0.0164 -0.0829 0.0004 0.0006 0.0510 -0.0367 0.0309 0.0111 0.0087 -0.0942 0.0064 -0.0040 -0.0629 0.0925 0.0432 -0.0581 -0.0822 0.0300 -0.0054 0.0608 0.0109 0.0613 -0.0267 -0.0456 -0.0253 ... -0.0290 0.0188 0.0517 -0.0599 -0.0028 -0.0684 0.0748 0.0464 -0.0591 0.1314 -0.1473 -0.1284 -0.1025 -0.1371 0.0944 -0.0051 0.0144 0.0801 0.0714 -0.0059 -0.0474 0.0266 -0.0107 0.0404 0.0444 -0.0797 0.0916 0.0518 0.0623 0.0743 -0.0904 0.0215 -0.0021 0.0493 0.0080 0.1592 -0.2151 0.0156 -0.0156 0.0259 -0.0259 -0.0580 -0.1010 -0.0332 -0.1293 0.0782 0.1718 -0.0657 0.0138 -0.0930
Dimension 38 0.0064 -0.0510 -0.0744 0.0046 -0.0046 -0.0812 -0.0450 -0.0557 0.0818 -0.1773 0.0056 0.0169 0.0685 -0.0035 0.0546 -0.0179 -0.0034 0.0152 -0.0533 -0.0888 0.0243 0.0084 0.0143 -0.0273 0.0300 -0.0026 0.0663 0.0086 0.0528 -0.0007 0.0003 0.0087 -0.0139 0.0444 0.0865 -0.0156 0.0019 0.0484 -0.0667 -0.0428 0.0265 0.0330 0.0072 0.0086 0.0380 -0.0574 -0.0514 0.0764 0.0536 0.0343 ... 0.0288 -0.0297 0.0246 -0.0289 -0.0009 -0.0796 -0.0579 -0.0504 0.0286 -0.1126 0.1074 0.1212 0.1099 0.1176 -0.0997 -0.0118 0.1747 -0.1536 0.0437 -0.0377 -0.0511 0.0125 0.0033 -0.0062 0.0479 -0.0532 -0.0025 0.0657 0.0391 0.0574 -0.0019 -0.0106 -0.0027 0.0275 -0.0703 0.1438 -0.0949 -0.0101 0.0101 0.0087 -0.0087 0.0195 0.1035 0.0240 -0.0117 -0.0499 0.1051 -0.0175 -0.0146 -0.0834
Dimension 39 0.0062 0.0242 0.1680 -0.0030 0.0030 0.0732 0.0507 0.0578 0.0238 0.0212 0.0415 -0.0071 -0.0039 -0.0312 0.0177 0.0014 0.0265 0.0363 0.0128 -0.0396 -0.0312 -0.0225 -0.0241 0.0250 0.0309 -0.0003 0.0263 0.0260 -0.0430 -0.0352 -0.0208 -0.0635 0.0453 0.0047 -0.0029 0.0165 -0.0089 0.0289 -0.0118 -0.0072 -0.0055 0.0269 -0.0157 0.0092 -0.0298 0.0308 0.0032 0.0134 0.0230 -0.0128 ... 0.0328 -0.0444 -0.0051 0.0024 0.0052 0.1410 -0.0053 0.0091 0.0055 0.0055 -0.0218 -0.0122 0.0031 -0.0070 0.0082 0.0130 0.0726 0.0100 -0.0478 -0.0118 0.0239 0.0020 0.0029 -0.0118 0.0112 0.0349 0.0816 0.0073 0.0516 0.0315 -0.0816 0.0189 -0.0120 -0.0437 0.1363 0.1078 -0.2221 -0.0137 0.0137 -0.0028 0.0028 -0.2968 -0.0178 0.0423 0.0745 -0.0219 0.0102 -0.0410 -0.0022 -0.0310
Dimension 40 0.0062 0.0194 0.0123 0.0102 -0.0102 0.0874 0.1587 -0.0139 -0.0420 -0.0060 -0.0031 0.0322 0.0385 0.0254 0.0191 0.0396 -0.0705 -0.0251 0.0026 -0.0082 0.0640 0.0211 0.0148 -0.0200 -0.0106 0.0035 0.0723 -0.0144 0.0173 -0.0621 -0.0194 0.0381 0.0448 0.0280 0.0141 0.0067 -0.0027 -0.0242 -0.0503 0.0367 0.0632 0.0486 -0.0137 -0.0078 -0.0907 -0.0002 -0.0135 -0.0697 -0.0390 -0.0271 ... -0.0007 0.0027 0.0041 0.0158 -0.0285 0.0191 0.0102 0.0091 0.0109 -0.0151 0.0357 0.0104 -0.0032 0.0421 -0.0287 -0.0109 0.0689 -0.0091 -0.0474 -0.0185 0.0194 0.0103 -0.0077 0.0009 0.0317 0.0704 0.0602 0.0053 0.0076 0.0283 -0.0114 -0.0355 0.0004 -0.0771 0.2160 0.0232 -0.1933 -0.0101 0.0101 0.0715 -0.0715 -0.0590 0.0065 0.0386 -0.0281 -0.0527 0.0913 0.0469 -0.0180 -0.1320
Dimension 41 0.0059 0.0022 0.0022 -0.0095 0.0095 -0.0286 -0.0456 0.0178 0.0265 -0.0791 0.0013 -0.0060 0.0101 -0.0127 0.0098 -0.0053 0.0083 0.0258 -0.0260 -0.0025 -0.0226 -0.0020 -0.0049 0.0132 0.0034 -0.0461 -0.0080 0.0343 0.0234 -0.0233 -0.0127 0.0113 -0.0117 0.0286 0.0614 -0.0364 -0.0278 0.0321 -0.0708 -0.0083 0.0472 0.0064 0.0140 0.0172 0.0049 -0.0031 -0.0125 0.0427 0.0324 -0.0420 ... -0.0178 0.0164 -0.0784 0.0388 0.0760 0.1120 -0.0265 0.0072 -0.0089 -0.0696 0.0427 0.0643 0.0725 0.0767 -0.0364 0.0335 -0.0140 -0.0842 -0.0532 0.0058 0.0018 -0.0033 -0.0009 0.0014 0.0004 0.0169 0.0004 0.0368 -0.0082 0.0039 -0.0357 -0.0052 -0.0175 0.0497 -0.2440 0.2788 -0.0632 0.0069 -0.0069 -0.0203 0.0203 0.0953 0.0549 -0.0022 0.0379 0.0021 -0.0104 -0.0914 0.0914 0.0094
Dimension 42 0.0059 -0.0598 0.0167 -0.0236 0.0236 -0.0024 -0.0677 0.0387 -0.0472 0.0506 0.0822 -0.0011 -0.0212 0.0002 -0.0256 -0.0073 -0.0031 -0.0499 0.0163 0.0472 -0.0358 0.0429 0.0112 0.0113 -0.0169 0.0085 -0.0123 0.0028 -0.0308 0.0506 0.0408 -0.0489 0.0019 -0.0943 -0.0136 0.0498 0.0257 -0.0350 0.0314 -0.0054 -0.0158 -0.0318 -0.0036 0.0161 0.0149 -0.0394 0.0234 0.0024 0.0305 0.0004 ... 0.0169 -0.0206 0.0176 -0.0100 -0.0154 0.0220 0.0287 -0.0602 0.0310 0.0352 -0.0418 -0.0124 0.0091 -0.0419 0.0145 0.0005 -0.0092 0.0930 -0.0404 0.0242 -0.0139 0.0037 0.0300 -0.0056 0.0083 -0.1148 -0.0013 0.0389 0.0523 0.0245 0.0727 0.0004 0.0005 -0.0325 0.2214 -0.2375 0.0305 0.0080 -0.0080 0.0325 -0.0325 0.1083 -0.1173 -0.0143 0.0281 0.0082 0.0768 -0.0686 -0.0468 -0.0150
Dimension 43 0.0057 -0.0332 -0.0813 -0.0333 0.0333 -0.0163 0.0379 0.0379 -0.0111 -0.0358 0.0154 0.0248 -0.0037 0.0343 -0.0049 -0.0052 0.0220 -0.0175 -0.0145 -0.0027 0.0523 0.0545 0.0602 -0.0575 -0.0276 0.0475 -0.0592 0.0164 -0.0076 -0.0239 0.0173 0.1383 -0.0808 0.0766 0.0101 -0.0670 0.0262 -0.0591 0.0299 0.0322 -0.0012 -0.0221 0.0128 -0.0873 0.0626 -0.0018 0.0209 -0.0027 -0.0056 0.0054 ... 0.0067 0.0008 -0.0236 -0.0233 0.0711 0.0594 -0.0062 0.0045 0.0137 -0.0253 0.0649 0.0247 -0.0059 0.0281 -0.0181 -0.0117 0.0800 -0.0475 -0.0315 0.0093 -0.0148 -0.0154 -0.0076 -0.0084 -0.0158 0.0550 0.0062 -0.0021 0.0229 0.0051 0.0288 0.0189 -0.0435 0.0285 0.0822 -0.1843 0.0753 -0.0086 0.0086 -0.0392 0.0392 -0.1332 -0.0218 0.0376 0.0985 -0.0350 0.0007 0.0169 -0.1186 0.0000
Dimension 44 0.0056 -0.0305 -0.0107 -0.0042 0.0042 -0.0499 -0.0585 0.0359 0.0069 -0.0512 -0.0155 -0.0138 -0.0211 -0.0258 -0.0152 0.1175 -0.1392 -0.0628 0.0376 0.1049 -0.0633 -0.0107 -0.0341 0.0574 0.0091 -0.0653 -0.0413 0.0662 -0.0128 -0.0281 0.0154 -0.0220 -0.0089 -0.0930 0.0295 0.0297 0.0000 0.0403 -0.0255 0.0199 0.1129 0.0291 0.0889 0.1133 -0.3970 0.0055 0.0383 -0.2493 0.0018 0.0443 ... -0.0272 0.0257 0.0337 -0.0127 -0.0381 -0.0148 -0.0047 -0.0156 -0.0063 -0.0306 0.0233 0.0373 0.0393 0.0330 -0.0194 0.0138 0.0340 -0.0411 0.0603 -0.0028 -0.0149 0.0053 0.0057 0.0090 0.0290 -0.0451 0.0107 0.0328 0.0459 0.0387 -0.0155 0.0254 0.0016 0.0009 0.0230 0.0134 -0.0396 -0.0042 0.0042 0.0047 -0.0047 0.0420 0.0253 -0.0830 -0.0104 -0.0455 0.0475 0.0732 -0.0752 -0.0652
Dimension 45 0.0056 0.0505 0.0625 0.0097 -0.0097 -0.0027 -0.0175 0.0420 -0.0467 0.0591 -0.0242 0.0035 -0.0081 -0.0308 0.0017 0.0795 -0.0708 -0.0374 0.0232 0.0614 -0.0149 0.0450 -0.0283 0.0048 0.0094 0.0006 -0.0695 0.0063 0.0298 0.0427 -0.0497 -0.0435 -0.0045 -0.0446 -0.0477 0.0672 0.0147 -0.0362 -0.0213 0.0733 0.0445 0.0151 0.0432 0.0637 -0.2469 0.0249 0.0321 -0.1822 0.0142 0.0184 ... 0.0061 -0.0151 -0.0911 0.0133 0.1320 0.0091 -0.0027 0.0108 0.0002 0.0551 -0.0239 -0.0627 -0.0850 -0.0697 0.0450 -0.0262 0.0564 0.0227 -0.0482 -0.0093 0.0225 -0.0177 -0.0107 -0.0254 -0.0338 0.0985 0.0199 -0.0516 -0.0346 -0.0390 -0.0601 -0.0269 -0.0007 0.0198 -0.1013 0.0878 0.0033 0.0085 -0.0085 -0.0425 0.0425 0.0303 -0.0233 0.1127 0.0248 0.0759 -0.0645 -0.1338 0.1287 0.0889
Dimension 46 0.0055 -0.0159 -0.0714 -0.0055 0.0055 -0.0378 -0.0473 -0.0605 0.0296 -0.0111 0.0675 0.0097 0.0079 0.0129 0.0102 0.0412 -0.0495 -0.0231 -0.0028 0.0208 -0.0029 -0.0126 0.0171 0.0193 -0.0045 -0.0162 0.0136 0.0203 -0.0027 0.0090 -0.0073 -0.0146 0.0328 -0.0639 -0.0045 0.0876 -0.0294 -0.0136 -0.0110 0.0453 0.0230 0.0091 0.0653 -0.0202 -0.0941 -0.0007 -0.0249 -0.0880 -0.0116 0.0555 ... 0.0119 -0.0039 -0.0086 0.0444 -0.0469 -0.0059 -0.0071 -0.0208 0.0339 -0.0247 0.0163 0.0328 0.0397 0.0335 -0.0246 0.0028 0.0105 0.0197 0.0143 0.0097 0.0136 0.0117 0.0174 -0.0073 0.0019 -0.0247 -0.0361 0.0300 -0.0260 -0.0045 0.0506 -0.0052 -0.0025 -0.0018 -0.1600 0.1086 0.0646 -0.0025 0.0025 -0.0112 0.0112 -0.1349 -0.0155 0.0679 0.1032 -0.0231 -0.0171 -0.0883 -0.0354 0.0867
Dimension 47 0.0054 0.0724 -0.0373 0.0605 -0.0605 0.0690 0.1332 -0.0221 -0.0384 0.0339 0.1451 0.0376 0.0300 0.0267 0.0149 -0.0003 -0.0185 -0.0326 -0.0287 -0.0383 0.0495 0.1007 0.0594 -0.0546 -0.0347 0.0370 0.0347 -0.0115 0.0070 -0.0361 -0.0082 0.0203 0.0447 0.0243 0.0208 -0.0062 0.0286 -0.0434 0.0276 -0.0437 -0.0553 0.0641 -0.0041 -0.0102 0.0366 -0.0343 0.0470 -0.0091 -0.0227 -0.0380 ... 0.0062 -0.0098 -0.0427 0.0310 0.0278 0.0089 -0.0211 0.0070 -0.0291 -0.0087 0.0456 0.0155 -0.0046 -0.0180 -0.0015 -0.0140 0.0480 0.0505 -0.0715 0.0112 0.0522 0.0217 -0.0136 0.0224 0.0206 0.0664 0.0325 -0.0571 -0.0551 -0.0309 -0.0415 -0.0369 0.0803 -0.1720 -0.0584 0.2654 -0.0612 0.0075 -0.0075 -0.0094 0.0094 0.1694 -0.0967 -0.0202 -0.0765 0.0411 -0.0454 0.0013 0.0642 0.0730
Dimension 48 0.0053 -0.0760 0.0535 -0.0142 0.0142 0.0396 0.1228 -0.0075 0.0231 0.0715 0.0582 0.0102 0.0127 0.0052 -0.0043 0.0369 -0.0335 -0.0302 -0.0278 -0.0097 0.0547 0.0473 0.0274 -0.0509 -0.0426 -0.0078 -0.0310 0.0755 -0.0122 0.0106 -0.0799 -0.0498 0.0892 0.0196 -0.0492 0.0104 0.0215 -0.0595 0.0275 0.0538 -0.0463 0.0170 0.0861 -0.0410 -0.0866 0.0280 0.0104 -0.1452 0.0177 -0.0240 ... -0.0533 0.0473 0.0160 -0.0401 0.0290 -0.0102 -0.0064 -0.0105 -0.0332 0.0112 0.0422 0.0016 -0.0318 -0.0419 0.0237 -0.0078 0.0593 0.0771 -0.0206 0.0187 -0.0752 0.0059 0.0044 0.0000 -0.0103 -0.0442 -0.0326 0.0482 0.0374 -0.0052 0.0858 0.0393 -0.0053 0.1156 -0.1767 -0.2412 0.3416 0.0076 -0.0076 -0.0533 0.0533 -0.0178 -0.0385 -0.0029 -0.1215 0.0725 -0.0168 -0.0844 0.0977 0.1547
Dimension 49 0.0052 0.0142 0.0279 0.0112 -0.0112 -0.0232 -0.1265 -0.0341 0.0045 -0.0219 -0.0745 -0.0187 -0.0173 -0.0067 -0.0091 -0.0116 0.0097 0.0145 0.0195 0.0195 -0.0140 -0.1197 -0.0258 0.0730 -0.0095 -0.1250 -0.0166 -0.0418 0.0950 -0.0551 0.0347 0.0247 -0.0202 -0.0457 0.0081 0.0712 -0.0722 -0.0525 0.0147 0.0183 -0.0132 -0.0222 0.0207 -0.0512 0.0718 0.0407 -0.0681 -0.0217 0.0333 -0.0891 ... 0.0075 0.0061 0.0137 0.0939 -0.1521 0.0268 0.0274 -0.0189 0.0233 0.0522 -0.1035 -0.0516 -0.0115 -0.0112 0.0116 0.0050 -0.0311 -0.0339 -0.0470 0.0166 0.0051 -0.0046 -0.0013 0.0315 0.0111 0.0274 -0.0023 -0.0235 -0.0021 -0.0194 0.0364 0.0146 0.0019 -0.0468 0.0107 -0.0580 0.0883 0.0050 -0.0050 -0.0266 0.0266 0.0482 0.0106 0.0370 -0.0420 0.0103 -0.0270 -0.0044 0.0719 0.0207
Dimension 50 0.0052 -0.0041 -0.0246 0.0005 -0.0005 0.0136 0.0074 0.0094 -0.0030 0.0255 0.0594 0.0088 -0.0004 -0.0134 0.0023 0.0422 0.0045 0.0003 -0.0171 0.0037 -0.0359 0.0011 0.0186 0.0227 0.0224 -0.0447 -0.0044 -0.0026 0.0322 0.0446 -0.0572 -0.0663 0.0474 0.0206 -0.0785 0.0235 0.0144 -0.0257 0.0094 0.0083 0.0131 0.0615 -0.0417 0.0227 -0.0899 0.0163 0.1331 -0.1260 0.0597 -0.1201 ... 0.0321 -0.0340 0.0009 0.0570 -0.0801 -0.0066 -0.0263 -0.0078 0.0229 0.0059 0.0220 -0.0141 -0.0264 -0.0176 0.0092 -0.0169 -0.0036 0.0267 0.0072 -0.0155 -0.0203 -0.0026 -0.0150 0.0159 -0.0153 0.0035 0.0158 -0.0149 -0.0194 0.0062 -0.0411 -0.0377 -0.0080 0.0659 0.0007 0.0710 -0.1306 0.0038 -0.0038 0.0430 -0.0430 -0.0524 -0.0137 -0.0247 -0.0493 0.0505 0.0178 0.0066 -0.0809 0.0735
Dimension 51 0.0051 0.0458 0.0039 0.0103 -0.0103 0.0320 0.1075 0.0608 -0.0206 0.0554 -0.0314 0.0171 0.0132 0.0090 0.0014 -0.0139 -0.0139 -0.0098 -0.0022 0.0044 0.0432 0.0762 0.0581 -0.0989 0.0117 0.0250 0.0037 -0.0415 0.0330 0.0506 -0.0233 -0.0285 0.0247 -0.0654 0.0215 0.0134 0.0295 0.0617 -0.0345 0.0401 -0.0403 -0.0138 0.0224 0.0137 0.0451 -0.0321 -0.0242 0.0460 -0.0601 0.0871 ... -0.0142 0.0151 -0.0201 0.0214 0.0037 0.0429 0.0202 0.0149 -0.0138 0.0090 0.0145 -0.0128 -0.0383 -0.0306 0.0237 0.0034 0.0044 0.0514 -0.0404 -0.0488 0.0315 -0.0015 -0.0125 -0.0225 -0.0060 0.0102 -0.0011 -0.0221 -0.0538 -0.0236 -0.0258 -0.0349 0.0229 0.0082 -0.0233 0.0752 -0.0590 -0.0043 0.0043 -0.0098 0.0098 -0.0565 0.0435 0.0035 0.0198 -0.0283 -0.0359 -0.0559 0.0670 0.0682
Dimension 52 0.0051 0.0070 0.0801 0.0032 -0.0032 0.0023 -0.0083 0.0915 -0.0144 -0.0321 -0.0006 0.0065 -0.0041 0.0046 -0.0023 -0.0460 -0.0087 0.0006 0.0217 0.0115 0.0190 0.0630 0.0352 -0.0150 -0.0767 0.0020 0.0751 -0.0159 -0.0460 -0.0711 0.0751 0.0441 -0.0321 -0.0333 0.0823 -0.0395 0.0602 0.0046 -0.0277 0.0003 -0.0526 -0.0408 0.0341 0.0100 0.1653 -0.0524 -0.0061 0.1196 -0.0672 -0.0557 ... 0.0051 -0.0126 0.0169 0.0043 -0.0338 -0.0078 -0.0019 0.0053 -0.0074 0.0202 -0.0311 -0.0133 -0.0024 -0.0130 -0.0037 -0.0133 0.0091 -0.0601 0.0442 0.0022 0.0195 0.0056 0.0087 -0.0369 0.0087 0.0250 0.0208 0.0079 0.0001 0.0042 -0.0108 0.0118 0.0130 -0.0532 -0.0524 0.0870 0.0136 -0.0033 0.0033 -0.0227 0.0227 -0.0736 -0.0157 -0.0222 0.0495 -0.0507 -0.0309 -0.0841 0.0591 0.0895
Dimension 53 0.0050 0.0106 -0.0722 -0.0032 0.0032 -0.0111 -0.0437 0.0111 -0.0437 -0.0528 -0.0929 -0.0131 -0.0219 -0.0122 -0.0044 0.0268 -0.0077 0.0010 0.0243 0.0332 -0.0669 0.0397 -0.0346 0.0047 0.0523 0.0212 -0.0349 -0.0465 0.0127 0.0727 0.0268 0.1121 -0.1845 -0.0160 -0.0434 0.0400 -0.0414 0.0132 0.0407 -0.0131 0.0153 -0.0456 0.0359 0.0730 -0.0942 0.0326 -0.0810 -0.0499 -0.0104 0.1738 ... 0.0212 -0.0067 -0.0014 0.0375 -0.0494 0.0866 0.0009 0.0213 0.0022 0.0238 -0.0418 -0.0267 -0.0177 -0.0019 -0.0080 -0.0206 -0.0164 -0.1095 -0.0321 -0.0004 -0.0002 -0.0183 0.0025 0.0150 -0.0020 0.0218 0.0090 -0.0062 -0.0043 -0.0028 -0.0078 -0.0069 -0.0069 -0.0354 0.0714 0.0380 -0.0866 -0.0014 0.0014 0.0079 -0.0079 -0.0549 0.0305 0.0145 0.0687 -0.0304 -0.0334 0.0063 -0.0058 -0.0131
Dimension 54 0.0050 -0.0567 -0.0262 -0.0138 0.0138 0.0100 0.0632 0.0096 -0.0087 -0.0372 -0.0167 -0.0036 0.0008 0.0034 0.0008 0.0317 0.0015 -0.0176 -0.0359 -0.0236 -0.0142 -0.0618 0.0694 0.0169 -0.0233 -0.0012 -0.0091 -0.0005 0.0084 -0.0393 -0.0890 0.0647 0.0039 0.0030 0.0304 -0.0661 0.0671 0.0644 0.1373 0.0151 0.0084 -0.0574 0.0251 -0.0736 -0.0442 0.0332 -0.0386 -0.1777 0.1526 -0.0595 ... -0.0561 0.0489 0.0165 -0.0458 0.0359 0.0415 -0.0198 0.0262 -0.0651 -0.0498 0.0722 0.0574 0.0319 -0.0007 -0.0333 -0.0180 0.0124 -0.0508 0.0339 0.0219 -0.0347 0.0073 0.0364 -0.0025 0.0230 -0.0749 0.0034 0.0660 0.0489 0.0416 0.0269 0.0521 0.0052 0.0182 -0.0726 -0.0021 0.0658 -0.0044 0.0044 -0.0259 0.0259 -0.0651 -0.0195 0.0063 0.0394 -0.0305 -0.0199 0.0275 -0.0049 -0.0317
Dimension 55 0.0050 -0.0228 -0.0137 -0.0204 0.0204 -0.0266 -0.0023 -0.0054 0.0107 -0.0210 0.0479 0.0137 0.0061 0.0059 -0.0070 -0.0246 -0.0242 -0.0130 0.0038 0.0325 0.0633 0.0807 -0.0132 -0.0264 -0.0760 -0.0636 -0.0050 0.0652 0.0031 0.0440 -0.0095 0.0414 -0.0529 0.0202 0.0463 0.0216 -0.0364 -0.1560 -0.0805 -0.0181 0.0220 -0.0173 0.0730 0.0096 0.1028 -0.0733 0.0011 0.0387 -0.0596 0.0748 ... 0.0229 -0.0267 -0.0093 -0.0238 0.0482 -0.0087 -0.0180 -0.0122 0.0056 -0.0335 0.0451 0.0378 0.0260 0.0268 -0.0149 0.0099 -0.0046 -0.0063 -0.0199 -0.0047 -0.0170 -0.0097 -0.0001 0.0013 -0.0075 -0.0544 -0.0225 0.0045 0.0266 0.0163 -0.0002 0.0092 -0.0293 0.1236 0.0359 -0.1081 -0.0343 -0.0020 0.0020 0.0100 -0.0100 -0.0046 0.0130 0.0211 -0.0172 -0.0187 0.0214 0.0411 -0.0060 -0.0571
Dimension 56 0.0050 -0.0057 -0.0133 -0.0162 0.0162 0.0442 0.0086 -0.0445 -0.0404 -0.0165 -0.0252 -0.0060 -0.0146 -0.0063 -0.0030 -0.0209 -0.0041 -0.0035 0.0186 0.0216 0.0506 -0.0551 -0.0116 -0.0175 -0.0025 -0.1075 0.0098 -0.1402 0.1445 -0.0411 0.0379 0.1074 -0.1119 0.0727 -0.0460 -0.0739 0.0492 0.0222 0.0583 -0.0560 0.0440 -0.0933 -0.0021 0.0233 0.0176 -0.0239 -0.0615 0.1014 0.0053 0.0227 ... 0.0009 0.0005 -0.0227 -0.1655 0.2658 0.0046 0.0122 -0.0025 -0.0042 0.0401 -0.0495 -0.0247 -0.0162 -0.0505 0.0036 -0.0126 0.0262 -0.0504 0.0165 0.0223 0.0028 -0.0143 0.0325 -0.0275 -0.0156 0.0541 0.0505 0.0056 0.0360 -0.0002 0.0029 0.0095 -0.0163 0.0405 -0.0687 0.0311 0.0082 -0.0075 0.0075 -0.0333 0.0333 -0.0209 -0.0666 -0.0288 0.1099 -0.1375 -0.0115 -0.1350 0.1250 0.0488
Dimension 57 0.0049 0.0076 -0.0756 0.0062 -0.0062 -0.0020 0.0041 -0.0173 0.0348 -0.0906 -0.1283 -0.0183 -0.0232 -0.0182 -0.0031 0.0260 0.0211 0.0103 0.0214 0.0075 -0.0225 -0.1156 -0.0505 0.1322 -0.0677 0.0686 -0.0798 -0.1431 0.0843 0.0870 -0.0255 0.0879 -0.1531 0.0747 -0.0690 -0.0581 0.0689 -0.0240 0.1537 0.0238 -0.1504 0.0020 -0.0836 0.0963 -0.1132 0.1203 -0.0546 -0.0622 -0.0536 0.0839 ... -0.0265 0.0391 -0.0207 -0.0093 0.0470 0.1049 0.0105 0.0502 -0.0268 0.0302 -0.0448 -0.0316 -0.0247 -0.0035 -0.0214 -0.0416 -0.0061 -0.1557 0.0081 -0.0104 0.0142 0.0007 0.0109 -0.0141 0.0047 0.0422 -0.0072 0.0035 -0.0116 -0.0004 0.0267 -0.0016 0.0134 -0.0515 0.0166 0.0038 0.0223 -0.0048 0.0048 -0.0002 0.0002 -0.0120 0.0269 0.0250 0.0675 -0.0169 -0.0283 0.0277 0.0057 -0.0744
Dimension 58 0.0049 0.0033 -0.0124 0.0052 -0.0052 0.0174 0.0764 -0.0164 0.0004 -0.0018 0.0123 -0.0019 -0.0095 -0.0143 -0.0003 -0.0633 -0.0213 0.0111 0.0269 0.0579 0.0570 0.0443 -0.0683 -0.0262 -0.0244 0.0369 -0.1124 0.0985 -0.0356 0.0593 -0.0348 0.0198 -0.0590 -0.0397 0.0305 0.0844 -0.1054 -0.0567 -0.1383 -0.0100 -0.0656 0.0468 0.1387 -0.0855 0.2260 0.0469 -0.2115 0.1553 -0.0368 -0.2384 ... 0.0036 -0.0076 -0.0097 -0.0027 0.0198 -0.0052 -0.0207 0.0235 -0.0155 -0.0210 0.0427 0.0088 -0.0174 -0.0029 -0.0023 -0.0099 0.0148 -0.0172 -0.0033 -0.0149 0.0037 0.0021 -0.0111 -0.0013 0.0033 0.0151 -0.0035 0.0020 -0.0043 0.0085 -0.0205 -0.0060 0.0131 -0.0123 -0.0327 0.0797 -0.0357 -0.0002 0.0002 -0.0038 0.0038 -0.0054 0.0115 0.0317 0.0165 0.0163 -0.0038 0.0826 -0.0950 -0.0502
Dimension 59 0.0048 0.0135 -0.0517 0.0134 -0.0134 -0.0250 -0.0501 -0.0507 0.0370 0.0234 0.0273 -0.0023 0.0071 -0.0007 0.0071 0.0132 0.0090 -0.0042 -0.0048 0.0052 -0.0822 0.0285 0.0612 0.0274 -0.0104 0.0234 0.1045 0.1620 -0.1969 -0.1356 -0.1087 0.0047 0.1212 0.0199 0.0460 -0.0024 -0.0728 0.0201 0.1308 -0.1403 -0.0646 0.0142 0.0674 0.0536 -0.0567 0.0934 -0.1297 -0.0313 0.0189 0.0215 ... 0.0141 0.0001 0.0064 0.0444 -0.0718 0.0315 -0.0514 -0.0190 0.0407 -0.0171 0.0065 0.0043 0.0104 0.0270 -0.0021 0.0056 0.0149 0.0498 -0.0263 0.0010 0.0281 -0.0198 -0.0203 -0.0034 -0.0001 0.0739 -0.0052 -0.0248 -0.0018 -0.0239 0.0171 0.0113 0.0092 -0.1151 -0.0085 -0.0309 0.1401 -0.0140 0.0140 0.0063 -0.0063 0.0090 0.0861 0.0320 0.0806 -0.0802 -0.0610 0.0287 -0.0261 0.0405
Dimension 60 0.0048 0.0207 0.0400 0.0033 -0.0033 0.0111 0.0373 -0.0145 -0.0404 -0.0408 0.0439 0.0143 0.0035 0.0041 0.0017 0.0479 0.0104 -0.0162 -0.0237 -0.0031 0.0827 -0.0673 0.0451 -0.1094 0.1036 0.1283 0.0457 0.0784 -0.1649 0.0150 0.0407 0.1512 -0.1729 -0.1591 0.0234 0.0726 0.0312 0.1157 0.1161 0.0056 -0.0587 0.0627 0.0071 -0.0703 -0.0407 -0.0855 0.1182 -0.2448 0.2318 0.0219 ... 0.0429 -0.0447 -0.0102 -0.0287 0.0565 -0.0333 -0.0289 -0.0004 0.0170 0.0013 0.0240 -0.0026 -0.0269 -0.0236 -0.0049 -0.0251 0.0026 -0.0332 0.0012 -0.0168 0.0192 -0.0028 -0.0111 -0.0221 0.0012 0.0112 -0.0006 -0.0123 -0.0207 -0.0030 -0.0115 -0.0148 0.0089 -0.0220 0.0065 0.0860 -0.0766 -0.0046 0.0046 -0.0056 0.0056 0.0322 0.0119 -0.0014 0.0526 -0.0401 0.0230 0.0319 -0.0563 -0.0650
Dimension 61 0.0048 -0.0284 0.0219 0.0059 -0.0059 0.0037 0.0410 0.0089 -0.0430 -0.0292 -0.0354 0.0033 -0.0000 -0.0011 0.0026 0.0132 -0.0001 0.0027 0.0030 0.0010 -0.1330 0.0048 0.0426 0.0053 0.1506 -0.0615 -0.1491 0.0081 0.1331 0.0705 0.0687 -0.0915 0.0185 0.0791 0.0879 -0.1182 0.0185 0.0241 -0.0671 0.1904 -0.0817 0.0629 -0.0361 -0.0953 0.0678 0.0779 -0.2204 -0.1261 0.1173 -0.0253 ... 0.0157 -0.0129 -0.0076 -0.0256 0.0479 -0.0389 0.0145 0.0006 0.0160 0.0299 -0.0042 -0.0295 -0.0394 -0.0093 0.0052 -0.0229 0.0381 -0.0445 -0.0022 -0.0084 -0.0147 0.0241 -0.0083 0.0061 0.0276 0.0070 0.0236 0.0424 0.0195 0.0252 0.0386 -0.0046 0.0060 -0.0302 -0.0450 0.0492 0.0245 0.0072 -0.0072 0.0061 -0.0061 -0.0041 -0.0005 0.0202 -0.0727 0.0923 0.0873 0.0104 -0.0455 -0.0859
Dimension 62 0.0048 0.0269 0.0040 0.0134 -0.0134 -0.0147 -0.0348 -0.0014 -0.0288 0.0502 0.0173 -0.0004 -0.0028 0.0007 -0.0014 0.0014 0.0135 -0.0030 -0.0011 0.0046 0.0233 -0.0278 0.0969 -0.0528 -0.0186 -0.1469 -0.0377 0.0693 0.0608 0.0657 -0.0862 -0.1920 0.1969 0.2288 0.0123 -0.1294 -0.0705 -0.1159 0.1065 -0.0500 0.0288 -0.0351 0.1065 -0.1727 -0.0007 -0.0080 0.1378 -0.0109 -0.0969 0.0337 ... -0.0051 0.0059 -0.0063 -0.2224 0.3171 0.0185 0.0062 0.0241 -0.0126 -0.0015 -0.0141 -0.0050 0.0007 -0.0022 0.0170 0.0186 -0.0059 0.0552 0.0272 -0.0151 0.0346 -0.0081 -0.0044 -0.0193 0.0043 0.0363 0.0270 -0.0352 0.0009 -0.0128 -0.0379 0.0118 0.0226 -0.1321 0.0307 0.1067 -0.0295 -0.0206 0.0206 -0.0250 0.0250 0.0149 0.0315 -0.0166 0.1738 -0.1847 -0.0386 0.0655 -0.0941 -0.0245
Dimension 63 0.0048 0.0082 -0.0206 -0.0106 0.0106 -0.0060 0.0081 -0.0294 0.0262 0.0103 -0.0054 0.0016 0.0070 0.0061 -0.0058 -0.0022 0.0039 0.0070 0.0019 0.0035 -0.0832 0.0233 -0.0906 0.0898 0.0503 0.0783 0.1524 -0.2110 0.0177 -0.0104 0.0185 -0.0064 0.0130 -0.1404 -0.1734 0.3440 -0.2137 -0.1881 -0.2218 0.1042 0.1361 0.0080 0.0693 -0.0813 0.0342 -0.0255 -0.1077 -0.0164 0.1604 -0.0239 ... -0.0088 0.0169 -0.0077 -0.1666 0.2425 0.0107 -0.0047 -0.0420 0.0574 -0.0224 0.0165 0.0178 0.0234 0.0385 -0.0044 0.0176 -0.0074 0.0338 -0.0080 -0.0058 0.0114 -0.0152 -0.0007 -0.0056 -0.0076 -0.0206 -0.0283 -0.0203 0.0034 -0.0037 -0.0159 -0.0056 -0.0179 0.0816 0.0508 -0.0665 -0.0573 -0.0075 0.0075 0.0264 -0.0264 0.0230 0.0303 0.0008 0.0420 -0.0552 -0.0075 0.0477 -0.0199 -0.0531
Dimension 64 0.0047 -0.0084 0.0042 0.0107 -0.0107 -0.0109 -0.0477 -0.0212 0.0090 0.0169 -0.0105 -0.0009 -0.0031 0.0013 -0.0010 0.0128 0.0093 -0.0026 -0.0016 -0.0061 0.0174 0.0436 0.0899 -0.1066 0.0136 0.1775 0.0415 -0.4380 0.1868 0.0239 -0.0257 -0.0481 0.0488 -0.0551 0.2727 0.0389 -0.2651 -0.0009 0.1436 -0.0330 0.0318 -0.1082 0.0283 -0.0203 0.0554 -0.1556 0.2234 -0.1452 0.1260 0.0341 ... 0.0178 -0.0162 0.0133 0.0483 -0.0885 -0.0056 0.0048 0.0166 -0.0107 -0.0129 -0.0199 -0.0030 0.0028 -0.0016 0.0034 0.0084 -0.0128 0.0146 -0.0436 0.0048 -0.0001 0.0172 -0.0140 0.0042 0.0145 0.0127 0.0290 0.0120 0.0071 0.0057 0.0055 0.0036 0.0088 -0.0897 -0.0107 0.0514 0.0360 -0.0037 0.0037 -0.0186 0.0186 -0.0278 0.0151 0.0195 -0.0452 -0.0158 0.0332 -0.0172 0.0617 -0.0269
Dimension 65 0.0047 0.0078 -0.0490 0.0318 -0.0318 -0.0243 -0.0666 -0.0129 0.0046 -0.0021 0.0605 -0.0036 -0.0063 0.0007 -0.0025 -0.0025 0.0057 0.0042 -0.0006 0.0040 0.2259 -0.1898 0.0634 -0.1343 -0.0208 0.1875 -0.2088 0.1494 -0.0982 -0.1228 0.2122 -0.1008 0.0722 -0.0535 -0.0609 0.0951 -0.0465 -0.0184 -0.0134 0.0318 0.0112 -0.1212 -0.0329 0.2009 0.0380 0.0104 0.1333 -0.0362 -0.1353 0.0017 ... 0.0033 -0.0068 -0.0150 -0.0814 0.1370 0.0062 -0.0072 0.0332 -0.0329 0.0223 -0.0246 -0.0191 -0.0105 -0.0012 0.0090 -0.0055 0.0098 -0.0214 -0.0252 0.0224 0.0044 0.0220 -0.0259 0.0144 0.0210 0.0569 0.0144 -0.0089 -0.0179 -0.0063 0.0214 -0.0090 0.0314 -0.1145 -0.0380 0.0633 0.0750 0.0067 -0.0067 0.0213 -0.0213 -0.0588 -0.0389 0.0193 -0.0814 0.0924 -0.0012 0.0134 0.0057 0.0136
Dimension 66 0.0047 0.0016 0.0095 0.0108 -0.0108 0.0118 0.0708 -0.0301 -0.0118 -0.0306 -0.0134 0.0069 -0.0009 -0.0029 0.0000 0.0017 0.0017 0.0012 -0.0023 -0.0093 -0.1705 -0.1109 0.0860 0.2070 -0.0308 0.0145 -0.0159 0.0650 -0.0488 0.1521 -0.1667 0.0644 -0.0769 0.1390 -0.1351 -0.0409 -0.1160 0.1010 -0.0123 -0.1513 0.0795 0.1402 -0.0529 -0.0702 0.2099 0.0888 -0.1515 -0.2552 -0.1054 0.1972 ... 0.0106 -0.0160 -0.0011 0.0375 -0.0499 -0.0195 0.0267 0.0152 -0.0200 0.0420 -0.0379 -0.0316 -0.0328 -0.0317 0.0111 -0.0241 0.0226 -0.0644 0.0102 0.0061 -0.0024 0.0112 -0.0075 0.0010 0.0022 -0.0137 -0.0099 -0.0102 -0.0074 -0.0040 -0.0007 -0.0060 0.0104 -0.0302 -0.0202 0.0074 0.0405 0.0019 -0.0019 0.0038 -0.0038 0.0297 -0.0673 0.0012 -0.0504 0.0409 0.0049 0.0469 -0.0432 0.0017
Dimension 67 0.0047 0.0072 0.0198 0.0062 -0.0062 0.0014 0.0089 0.0166 0.0166 -0.0034 -0.0086 0.0012 0.0026 -0.0026 0.0033 0.0033 0.0020 0.0031 -0.0006 -0.0111 -0.0689 0.0124 0.0338 0.1207 -0.1239 0.1150 0.2485 -0.2052 -0.0811 0.0208 -0.0330 -0.0027 0.0024 0.0111 -0.0304 -0.0989 0.1658 0.1051 -0.1074 0.0061 -0.0723 0.0331 0.2801 -0.0246 -0.0390 -0.0594 0.0851 0.0374 0.0090 0.0423 ... -0.0041 0.0003 -0.0151 0.0849 -0.0922 -0.0181 0.0053 0.0057 -0.0067 0.0328 -0.0302 -0.0287 -0.0238 -0.0164 0.0154 -0.0079 0.0187 -0.0220 0.0016 0.0037 0.0031 0.0010 -0.0008 -0.0070 0.0007 0.0099 0.0081 -0.0005 -0.0010 -0.0078 0.0088 -0.0085 0.0053 0.0181 -0.0715 0.0336 0.0280 0.0058 -0.0058 -0.0072 0.0072 0.0283 -0.0136 -0.0172 -0.0354 0.0470 0.0059 -0.0499 0.0533 0.0208
Dimension 68 0.0047 0.0049 -0.0280 0.0015 -0.0015 -0.0154 0.0236 -0.0016 0.0156 -0.0682 -0.0357 0.0018 -0.0074 -0.0011 -0.0019 0.0040 0.0083 0.0011 0.0093 0.0088 0.0343 -0.1060 0.1201 0.2042 -0.3742 0.0162 -0.1151 0.0137 0.0462 0.0400 0.1766 -0.2043 0.0984 -0.1765 0.2586 0.0529 -0.1588 0.1357 -0.0699 0.1884 -0.2508 0.2285 -0.0964 -0.1129 -0.0328 -0.0279 0.0570 0.0065 -0.0407 0.1271 ... 0.0071 -0.0001 -0.0062 -0.0546 0.0856 0.0189 0.0011 0.0025 0.0141 0.0306 -0.0348 -0.0214 -0.0144 0.0064 -0.0032 -0.0158 0.0125 -0.0957 0.0156 0.0030 0.0099 -0.0009 -0.0040 -0.0094 -0.0006 0.0182 -0.0040 0.0007 -0.0048 -0.0065 0.0197 -0.0105 -0.0029 0.0085 -0.0038 -0.0202 0.0176 0.0019 -0.0019 0.0072 -0.0072 0.0003 -0.0029 0.0035 -0.0089 0.0387 0.0053 -0.0033 0.0007 -0.0205
Dimension 69 0.0047 -0.0085 -0.0064 -0.0140 0.0140 0.0107 0.0414 -0.0110 0.0357 -0.0690 -0.0570 0.0077 -0.0042 0.0009 -0.0045 0.0034 0.0026 0.0006 0.0031 0.0009 -0.0127 0.2888 0.1466 -0.1207 -0.1706 -0.1079 -0.0959 -0.1097 0.2087 0.1614 0.2216 -0.3110 0.1193 0.0663 -0.2733 0.0569 0.0760 -0.0886 0.0352 -0.1400 0.0670 0.0005 -0.0242 0.0886 -0.0726 -0.0113 -0.0283 0.0452 0.0156 0.0978 ... 0.0089 -0.0088 0.0150 0.1143 -0.1825 0.0060 0.0144 0.0031 0.0044 0.0063 0.0107 -0.0109 -0.0190 -0.0107 -0.0124 -0.0318 0.0215 -0.0896 -0.0098 0.0018 0.0021 0.0051 0.0128 -0.0186 -0.0035 -0.0158 0.0094 0.0290 0.0196 0.0092 -0.0028 0.0193 -0.0099 0.0270 -0.0129 -0.0461 0.0382 -0.0133 0.0133 -0.0343 0.0343 0.0260 -0.0065 -0.0070 0.0893 -0.1141 0.0003 0.0312 -0.0171 -0.0626
Dimension 70 0.0047 -0.0004 0.0121 -0.0121 0.0121 0.0228 0.0145 0.0050 0.0415 -0.0072 -0.0018 -0.0023 0.0053 0.0025 -0.0010 0.0075 0.0044 -0.0017 -0.0053 -0.0202 0.2445 -0.1877 0.0111 -0.0218 -0.1707 0.0805 0.0364 0.0057 -0.0713 -0.0460 -0.0047 -0.0084 0.0403 -0.0495 -0.0620 -0.0132 0.2223 -0.0453 0.1044 0.1037 -0.0449 -0.0910 -0.1408 0.0546 0.1054 -0.0649 -0.0003 -0.1675 0.1667 -0.0042 ... -0.0005 0.0019 0.0032 0.0312 -0.0483 -0.0202 0.0088 -0.0158 0.0057 -0.0093 0.0187 0.0139 0.0156 0.0042 -0.0061 0.0089 0.0069 0.0090 0.0308 0.0071 0.0044 -0.0136 0.0203 -0.0047 -0.0023 -0.0341 -0.0109 0.0052 0.0121 0.0041 -0.0150 0.0081 -0.0115 0.0410 0.0261 -0.0144 -0.0490 -0.0131 0.0131 -0.0080 0.0080 0.0344 -0.0015 -0.0153 0.0798 -0.1226 -0.0118 0.0179 -0.0419 0.0225
Dimension 71 0.0047 -0.0036 -0.0013 -0.0101 0.0101 -0.0028 0.0074 0.0139 -0.0056 -0.0249 0.0265 -0.0057 -0.0051 0.0001 -0.0037 0.0032 -0.0036 -0.0019 0.0014 0.0154 -0.0134 0.0904 0.0964 0.0399 -0.2267 0.1541 -0.0432 -0.1054 0.0049 -0.1384 0.0155 -0.0496 0.1206 0.0866 -0.0793 -0.0559 -0.0733 0.1313 -0.1143 -0.2447 0.2850 0.0699 0.0591 -0.0333 0.2071 -0.0037 0.1222 -0.2320 0.0232 -0.2267 ... 0.0012 0.0020 -0.0073 0.0470 -0.0528 -0.0217 -0.0171 -0.0078 0.0084 -0.0157 0.0168 0.0208 0.0219 0.0232 -0.0164 0.0020 -0.0226 -0.0032 0.0232 0.0010 0.0037 -0.0164 0.0093 -0.0104 0.0042 -0.0118 -0.0043 0.0080 0.0100 0.0060 0.0108 0.0123 -0.0098 0.0235 -0.0035 0.0004 -0.0169 -0.0020 0.0020 0.0074 -0.0074 -0.0058 0.0195 0.0191 0.0505 -0.0312 0.0010 -0.0012 -0.0280 -0.0119
Dimension 72 0.0047 0.0100 0.0107 0.0083 -0.0083 -0.0180 -0.0229 -0.0018 -0.0313 0.0146 0.0393 0.0037 -0.0041 0.0000 0.0004 0.0059 0.0029 0.0003 -0.0060 -0.0016 -0.1433 0.1645 0.1019 -0.0553 0.0617 -0.1185 0.0084 0.0090 0.0554 -0.1150 0.1744 -0.0610 0.0446 -0.0566 0.0740 -0.0269 0.3355 -0.3027 0.1082 0.0785 -0.0957 0.0483 -0.2270 -0.0192 0.0763 0.0504 -0.2356 -0.1120 0.1635 -0.0058 ... 0.0041 -0.0059 0.0008 -0.0325 0.0435 -0.0143 -0.0198 0.0200 -0.0194 -0.0228 -0.0042 0.0204 0.0239 0.0095 0.0020 0.0218 -0.0083 0.0154 0.0097 -0.0047 0.0039 -0.0014 -0.0114 0.0063 0.0029 0.0241 0.0132 -0.0132 -0.0050 -0.0021 -0.0197 -0.0046 0.0093 -0.0324 -0.0038 0.0650 -0.0348 0.0024 -0.0024 -0.0023 0.0023 0.0193 0.0203 0.0116 -0.0456 0.0032 0.0132 0.0075 -0.0011 0.0231
Dimension 73 0.0046 -0.0083 -0.0127 -0.0007 0.0007 0.0120 0.0193 0.0031 0.0045 0.0127 0.0156 0.0032 0.0096 0.0097 0.0081 0.0008 0.0013 -0.0024 -0.0116 -0.0270 -0.1096 0.4038 -0.1673 -0.0247 -0.0019 0.0390 0.0620 0.0540 -0.0926 -0.1674 0.1229 -0.0079 0.0596 -0.0506 -0.0697 0.0253 -0.1127 0.3171 0.1567 0.0443 -0.0378 0.1440 -0.2327 -0.3242 -0.0471 0.0938 0.0479 0.0515 -0.2829 0.1178 ... -0.0146 0.0164 0.0046 -0.0562 0.0700 -0.0017 0.0061 -0.0023 -0.0078 -0.0223 0.0112 0.0264 0.0374 0.0237 -0.0110 0.0227 0.0009 0.0258 0.0119 0.0139 -0.0070 -0.0002 0.0085 0.0041 0.0036 -0.0209 -0.0027 -0.0001 0.0097 0.0026 0.0026 0.0044 -0.0023 0.0183 0.0099 -0.0247 -0.0012 -0.0035 0.0035 0.0112 -0.0112 -0.0019 -0.0060 -0.0080 0.0237 -0.0428 0.0015 -0.0126 0.0168 -0.0012
Dimension 74 0.0046 -0.0101 -0.0140 0.0048 -0.0048 0.0045 0.0417 -0.0082 -0.0404 -0.0100 -0.0241 0.0079 -0.0027 -0.0048 0.0049 -0.0031 -0.0002 0.0034 0.0009 -0.0061 -0.1708 -0.2207 0.0695 0.1623 0.1546 0.1624 -0.0424 -0.0457 -0.0424 -0.0333 0.0558 -0.0729 0.0584 -0.1042 0.1076 -0.0470 0.3716 -0.1975 0.0277 -0.2382 0.0981 0.0993 0.2689 -0.2658 0.0181 0.0131 0.1541 0.0101 -0.2441 0.0941 ... -0.0285 0.0312 0.0087 -0.0283 0.0246 0.0445 0.0001 0.0146 -0.0145 -0.0193 0.0211 0.0231 0.0209 0.0208 -0.0200 -0.0045 0.0173 -0.0098 0.0091 -0.0014 -0.0073 0.0040 0.0073 -0.0015 0.0063 -0.0036 -0.0158 0.0144 -0.0127 -0.0033 0.0359 -0.0137 0.0033 -0.0419 0.0026 0.0044 0.0287 -0.0017 0.0017 0.0156 -0.0156 -0.0142 0.0257 0.0274 0.0607 -0.0344 0.0054 -0.0165 0.0161 -0.0538
Dimension 75 0.0046 0.0059 0.0032 0.0216 -0.0216 -0.0001 0.0069 0.0028 0.0128 -0.0138 -0.0341 -0.0073 -0.0129 -0.0070 -0.0090 -0.0114 0.0013 0.0001 0.0107 0.0215 -0.0021 0.0514 -0.2930 0.1170 0.0290 0.0693 -0.0653 -0.0689 0.0334 -0.0010 0.2606 -0.0858 -0.0455 -0.0090 -0.1847 0.0190 0.0521 0.1032 -0.0105 -0.1880 0.0898 -0.0327 0.2535 -0.0384 0.0500 -0.0290 -0.0549 -0.0101 0.1070 -0.0423 ... 0.0087 -0.0115 0.0009 -0.0463 0.0623 -0.0029 0.0140 0.0495 -0.0512 0.0386 -0.0496 -0.0420 -0.0414 -0.0302 0.0159 -0.0206 0.0019 -0.0640 -0.0051 -0.0022 -0.0002 0.0205 -0.0194 0.0059 0.0083 0.0279 0.0169 -0.0131 -0.0222 -0.0087 0.0034 -0.0051 0.0232 -0.1013 -0.0089 0.0420 0.0538 0.0094 -0.0094 -0.0005 0.0005 -0.0219 -0.0121 0.0098 -0.0927 0.0961 -0.0013 0.0095 0.0185 0.0176
Dimension 76 0.0046 -0.0017 0.0172 0.0087 -0.0087 -0.0040 -0.0145 -0.0031 0.0094 0.0037 0.0508 0.0019 0.0123 0.0100 0.0031 -0.0012 -0.0016 -0.0021 -0.0052 -0.0114 -0.0412 -0.1301 0.4347 -0.0975 -0.0700 -0.0525 0.1008 -0.0031 -0.0146 0.0229 0.1476 0.0079 -0.0742 0.0287 -0.2813 0.0167 0.0357 0.2142 -0.0323 0.2151 -0.0273 -0.1430 0.2372 -0.1944 -0.2346 0.0374 -0.0257 0.2354 0.0474 -0.1526 ... 0.0082 -0.0043 0.0110 -0.0398 0.0368 0.0080 -0.0092 -0.0162 0.0177 -0.0072 0.0056 0.0078 0.0088 0.0172 0.0012 0.0107 0.0061 0.0244 -0.0109 0.0152 -0.0047 0.0056 -0.0125 0.0224 0.0137 0.0094 0.0087 -0.0016 0.0066 0.0014 -0.0083 0.0135 0.0016 -0.0481 0.0376 -0.0255 0.0267 0.0006 -0.0006 0.0036 -0.0036 -0.0218 -0.0002 0.0087 -0.0655 -0.0103 -0.0088 0.0508 0.0306 -0.0054
Dimension 77 0.0046 0.0093 0.0105 -0.0043 0.0043 -0.0061 -0.0198 0.0121 -0.0366 -0.0348 -0.0081 -0.0012 -0.0076 0.0033 -0.0038 0.0012 -0.0020 -0.0038 0.0042 0.0118 -0.0405 -0.0251 0.0693 -0.0516 0.0934 -0.2662 0.0972 0.0471 0.0537 0.0994 0.2051 -0.1035 -0.0427 0.1351 -0.1340 -0.0644 0.0115 0.0005 -0.0600 -0.0105 -0.0150 0.0416 0.0000 0.0673 0.0884 -0.0837 0.1170 -0.0987 -0.0161 0.0958 ... 0.0018 -0.0002 -0.0023 0.0294 -0.0368 0.0022 -0.0011 0.0076 -0.0078 0.0120 -0.0276 -0.0146 -0.0025 0.0032 0.0023 0.0042 0.0024 -0.0376 0.0028 -0.0088 0.0143 -0.0116 0.0021 -0.0027 -0.0012 0.0162 -0.0029 0.0004 -0.0025 -0.0056 -0.0032 0.0007 -0.0005 -0.0234 0.0136 0.0252 -0.0206 -0.0034 0.0034 -0.0010 0.0010 -0.0030 0.0060 0.0301 0.0340 -0.0301 -0.0223 -0.0067 0.0100 0.0150
Dimension 78 0.0046 -0.0122 0.0454 0.0107 -0.0107 -0.0177 0.0320 0.0360 0.0238 -0.0142 0.0349 0.0039 0.0003 0.0036 -0.0065 0.0000 -0.0115 -0.0080 -0.0030 0.0067 -0.0171 -0.1392 -0.0143 0.2137 -0.1546 0.0003 -0.0706 0.0251 0.0289 -0.0238 0.0150 0.0916 -0.0800 0.0816 0.0004 0.0118 -0.1257 -0.1031 0.0749 -0.1917 0.1290 0.0744 -0.0747 -0.0935 -0.2098 -0.0112 -0.1264 0.2148 0.1785 -0.1078 ... 0.0056 -0.0098 0.0028 -0.1241 0.1666 -0.0127 0.0032 0.0024 -0.0142 0.0141 0.0011 -0.0024 -0.0104 -0.0016 0.0017 -0.0105 0.0306 -0.0078 -0.0091 0.0046 -0.0218 0.0125 -0.0062 0.0123 0.0182 -0.0133 -0.0046 0.0193 -0.0061 0.0122 0.0195 -0.0058 0.0145 -0.0215 0.0355 -0.0264 0.0069 0.0087 -0.0087 0.0098 -0.0098 0.0235 -0.0329 0.0021 -0.1167 0.0688 0.0380 0.0207 -0.0085 0.0132
Dimension 79 0.0046 -0.0000 0.0428 -0.0132 0.0132 0.0193 0.0896 -0.0152 0.0494 0.0206 -0.0795 -0.0033 0.0142 0.0036 0.0035 -0.0096 -0.0093 -0.0002 -0.0051 -0.0069 -0.1703 -0.0240 0.0364 0.1025 0.0700 -0.0427 0.1817 0.0262 -0.0947 -0.1143 0.2660 0.0073 -0.0615 -0.0097 0.0146 0.0008 -0.0219 0.0447 -0.0502 0.1559 -0.1182 -0.1247 0.0852 0.1410 0.2740 -0.0119 0.0486 -0.2499 -0.1196 0.0866 ... -0.0120 0.0050 0.0009 -0.1266 0.1732 -0.0147 0.0378 -0.0361 0.0251 0.0187 -0.0011 -0.0087 -0.0165 0.0024 0.0153 0.0137 -0.0000 0.0327 -0.0291 -0.0140 0.0008 -0.0128 0.0147 -0.0033 -0.0173 -0.0451 -0.0283 -0.0163 -0.0110 -0.0096 -0.0026 -0.0103 -0.0099 0.0644 0.0569 -0.1006 -0.0140 -0.0046 0.0046 0.0124 -0.0124 0.0429 0.0176 -0.0409 0.0234 -0.0285 -0.0166 -0.0214 0.0340 0.0143
Dimension 80 0.0046 -0.0029 -0.0197 -0.0029 0.0029 -0.0064 0.0108 -0.0004 -0.1058 -0.0143 -0.0137 0.0125 -0.0015 0.0073 0.0029 0.0078 -0.0028 -0.0026 -0.0030 -0.0073 -0.2849 -0.0712 0.3401 -0.0681 0.3021 0.0292 -0.0461 0.0444 -0.0228 0.0059 0.1408 -0.0654 0.0079 0.0608 0.1235 0.0186 -0.2426 -0.0446 -0.0770 -0.1331 -0.1289 0.1599 0.0030 0.2606 -0.0382 0.1092 0.0308 0.0196 -0.0701 -0.2611 ... -0.0093 0.0160 -0.0089 0.0263 -0.0215 -0.0069 0.0230 0.0369 -0.0319 0.0144 -0.0349 -0.0068 0.0071 0.0122 0.0027 0.0126 0.0069 -0.0342 0.0020 0.0124 -0.0063 0.0025 0.0099 -0.0060 0.0044 -0.0052 -0.0016 0.0034 0.0160 0.0077 0.0125 0.0215 -0.0046 0.0646 -0.0340 -0.0160 -0.0021 0.0051 -0.0051 -0.0046 0.0046 0.0194 -0.0223 -0.0091 -0.0225 0.0534 -0.0226 0.0081 0.0187 -0.0036
Dimension 81 0.0046 0.0126 0.0032 0.0128 -0.0128 0.0050 -0.0076 -0.0120 -0.0107 -0.0078 0.0901 -0.0005 -0.0128 -0.0115 -0.0090 -0.0028 -0.0073 -0.0034 0.0004 0.0214 0.0369 -0.1058 0.1171 0.0211 -0.1006 -0.2596 0.1521 0.0181 0.0268 -0.0570 -0.1230 0.0301 0.0416 0.0969 0.1295 -0.0609 -0.0532 -0.1982 -0.0204 0.0261 -0.0421 0.0003 0.1643 -0.1024 -0.0218 -0.0820 -0.0877 0.0335 0.0186 0.3265 ... 0.0418 -0.0550 -0.0015 0.0478 -0.0635 -0.0255 -0.0275 -0.0094 -0.0076 -0.0215 0.0247 0.0204 0.0218 -0.0034 -0.0015 0.0088 -0.0107 0.0086 -0.0369 0.0024 -0.0041 -0.0088 -0.0232 0.0179 -0.0046 -0.0403 -0.0390 -0.0288 -0.0278 -0.0125 -0.0318 -0.0343 0.0105 0.0172 0.0266 0.0097 -0.0538 0.0029 -0.0029 0.0497 -0.0497 0.0027 -0.0352 -0.0045 -0.0792 -0.0009 -0.0231 0.0074 0.0141 0.1129
Dimension 82 0.0045 0.0191 -0.0185 -0.0034 0.0034 0.0089 -0.0181 0.0068 0.0191 0.0129 -0.0178 -0.0056 0.0052 0.0109 -0.0010 0.0017 0.0094 0.0094 0.0068 0.0005 -0.1069 0.1712 0.0371 -0.0255 -0.0077 0.0379 0.0166 0.1069 -0.1078 0.4068 -0.2382 -0.0890 -0.0117 -0.0542 0.1713 -0.0056 -0.0453 -0.0197 -0.1215 0.0797 0.0404 0.0092 0.0229 -0.0125 0.0063 -0.1213 0.0900 -0.0059 0.1049 0.0887 ... -0.0060 0.0236 -0.0028 -0.0800 0.1150 0.0139 0.0025 -0.0347 0.0561 0.0078 -0.0020 -0.0178 -0.0062 0.0379 0.0000 0.0085 -0.0164 0.0277 -0.0136 -0.0070 0.0120 -0.0010 -0.0040 0.0073 -0.0056 0.0440 -0.0136 -0.0170 -0.0244 -0.0131 0.0102 -0.0208 -0.0130 0.0580 0.0582 -0.0472 -0.0650 0.0050 -0.0050 0.0173 -0.0173 0.0096 0.0319 -0.0150 -0.0451 0.0822 -0.0142 -0.0519 0.0479 0.0508
Dimension 83 0.0045 0.0122 -0.0271 -0.0030 0.0030 0.0427 0.0537 -0.0174 -0.0347 0.0450 0.0035 -0.0078 -0.0081 -0.0116 0.0030 -0.0040 0.0011 0.0090 0.0120 0.0071 -0.0313 0.0731 0.1597 -0.0276 -0.1456 -0.1162 -0.1000 0.0300 0.1055 0.0448 0.0147 0.0813 -0.1314 -0.0265 0.0911 -0.1091 -0.0021 0.2804 -0.0797 0.0414 0.1394 -0.1521 0.1510 -0.0133 0.1109 -0.0553 -0.0397 -0.0851 0.0909 0.0539 ... -0.0144 0.0155 -0.0053 0.0025 0.0054 0.0612 0.0024 -0.0054 0.0125 -0.0297 0.0419 0.0208 0.0110 0.0012 -0.0039 0.0110 -0.0186 0.0530 -0.0040 0.0017 -0.0083 -0.0046 -0.0064 0.0151 -0.0192 0.0312 -0.0077 -0.0148 -0.0130 -0.0092 -0.0492 -0.0020 -0.0163 0.0863 0.0207 -0.0431 -0.0525 0.0067 -0.0067 0.0310 -0.0310 -0.0060 -0.0157 0.0264 -0.0164 0.0363 -0.0284 0.0266 -0.0390 0.0439
Dimension 84 0.0045 -0.0151 0.0386 -0.0012 0.0012 0.0136 0.0496 0.0245 -0.0048 -0.0598 -0.0254 0.0050 -0.0053 -0.0046 -0.0036 0.0079 0.0076 0.0044 0.0052 0.0117 0.0758 0.0301 0.0730 -0.0971 -0.0430 -0.0168 0.1183 -0.0546 -0.0362 0.0928 -0.2045 -0.0459 0.0821 -0.0245 -0.0942 0.0267 -0.0190 0.1137 0.2555 -0.2210 -0.2106 -0.0250 0.1211 0.1957 -0.0052 0.0579 0.0032 -0.0270 -0.0444 -0.0441 ... 0.0383 -0.0429 0.0179 -0.2050 0.2531 -0.0639 -0.0116 -0.0283 0.0453 0.0163 -0.0091 -0.0091 -0.0121 -0.0149 -0.0147 -0.0284 -0.0043 -0.0691 0.0121 0.0065 -0.0079 0.0057 -0.0001 -0.0102 0.0024 -0.0342 -0.0299 0.0003 0.0045 0.0082 0.0461 -0.0056 -0.0049 0.0161 0.0360 -0.0442 -0.0077 -0.0033 0.0033 0.0179 -0.0179 0.0543 0.0002 -0.0257 0.0229 -0.0182 0.0337 0.0453 -0.0894 -0.0458
Dimension 85 0.0045 0.0197 0.0201 -0.0009 0.0009 0.0041 0.0647 0.0102 0.0131 0.1090 0.0405 0.0108 0.0069 0.0042 -0.0071 0.0065 -0.0195 -0.0063 -0.0029 0.0091 -0.0371 -0.1177 -0.0878 0.1874 -0.0184 -0.0986 0.0809 -0.0457 0.0517 0.0974 0.2247 0.0538 -0.2071 0.1224 0.0895 -0.1085 -0.1108 0.0111 0.2304 -0.1306 -0.1560 0.1598 -0.1006 -0.1278 -0.0876 -0.1310 0.1746 0.0823 0.1272 -0.1666 ... -0.0462 0.0453 -0.0102 0.0706 -0.0805 -0.0854 0.0290 -0.0225 0.0180 0.0175 -0.0075 -0.0125 -0.0149 -0.0052 0.0323 0.0230 0.0415 0.1621 -0.0056 -0.0123 0.0011 -0.0177 0.0022 -0.0036 -0.0070 -0.0219 -0.0454 -0.0444 -0.0198 -0.0103 -0.0581 -0.0080 0.0013 0.0889 -0.0032 -0.0053 -0.0677 -0.0105 0.0105 0.0110 -0.0110 -0.0087 -0.0290 -0.0079 0.0039 -0.0813 -0.0482 0.0235 0.0239 0.0714

85 rows × 217 columns

Discussion 2.2: Perform Dimensionality Reduction

I reduced the PCA to 85 components based on the 80-20 rule: they explained 80% of the variation.

Step 2.3: Interpret Principal Components

Now that we have our transformed principal components, it's a nice idea to check out the weight of each variable on the first few components to see if they can be interpreted in some fashion.

As a reminder, each principal component is a unit vector that points in the direction of highest variance (after accounting for the variance captured by earlier principal components). The further a weight is from zero, the more the principal component is in the direction of the corresponding feature. If two features have large weights of the same sign (both positive or both negative), then increases in one tend expect to be associated with increases in the other. To contrast, features with different signs can be expected to show a negative correlation: increases in one variable should result in a decrease in the other.

  • To investigate the features, you should map each weight to their corresponding feature name, then sort the features according to weight. The most interesting features for each principal component, then, will be those at the beginning and end of the sorted list. Use the data dictionary document to help you understand these most prominent features, their relationships, and what a positive or negative value on the principal component might indicate.
  • You should investigate and interpret feature associations from the first three principal components in this substep. To help facilitate this, you should write a function that you can call at any time to print the sorted list of feature weights, for the i-th principal component. This might come in handy in the next step of the project, when you interpret the tendencies of the discovered clusters.
In [55]:
# Map weights for the first principal component to corresponding feature names
# and then print the linked values, sorted by weight.
# HINT: Try defining a function here or in a new cell that you can reuse in the
# other cells.

# I borrowed this function from the helper functions used in the practice projects
def pca_weight(pca, df, i):
    '''
    INPUT:
        pca - the result of instantiation of PCA in scikit learn
        df - associated dataframe
        i - component reference (zero-based) 
    OUTPUT:
        df - dataframe of linked values, sorted by weight
    '''
    df = pd.DataFrame(pca.components_, columns=list(df.columns))
    weights = df.iloc[i].sort_values(ascending=False)
    return weights
In [56]:
pca_wgt_0 = pca_weight(pca_85, azdias_scaled, 0)
print(pca_wgt_0)
LP_STATUS_GROB_1.0      0.184073
HH_EINKOMMEN_SCORE      0.179633
PLZ8_ANTG3              0.171112
PLZ8_ANTG4              0.166500
PLZ8_BAUMAX             0.163261
CAMEO_WEALTH_5.0        0.144780
ORTSGR_KLS9             0.142604
EWDICHTE                0.140809
FINANZ_HAUSBAUER        0.140388
CAMEO_LIFESTAGE_1.0     0.134500
LP_STATUS_FEIN_1.0      0.128207
KBA05_ANTG4             0.123024
PLZ8_ANTG2              0.116421
KBA05_ANTG3             0.112349
ANZ_HAUSHALTE_AKTIV     0.110638
GREEN_AVANTGARDE_0.0    0.109869
ARBEIT                  0.108635
CAMEO_DEUG_2015_9.0     0.108201
MOVEMENT_MAINSTREAM     0.104953
LP_STATUS_FEIN_2.0      0.100443
RELAT_AB                0.099671
LP_FAMILIE_FEIN_1.0     0.095826
LP_FAMILIE_GROB_1.0     0.095826
FINANZTYP_1.0           0.095817
FINANZ_SPARER           0.095509
CAMEO_DEUG_2015_8.0     0.090891
ZABEOTYP_5.0            0.072074
SEMIO_PFLICHT           0.066241
GEBAEUDETYP_3.0         0.062474
CAMEO_DEU_2015_8A       0.062344
SEMIO_REL               0.060851
DECADE_90s              0.058436
REGIOTYP                0.057043
CAMEO_DEU_2015_9B       0.056352
SEMIO_RAT               0.056288
GFK_URLAUBERTYP_12.0    0.056278
CAMEO_DEU_2015_9C       0.055880
CAMEO_DEU_2015_9D       0.055506
W_KEIT_KIND_HH          0.054966
SEMIO_TRADV             0.053114
OST_WEST_KZ_O           0.047194
SEMIO_MAT               0.045937
NATIONALITAET_KZ_2.0    0.044121
SEMIO_FAM               0.042758
FINANZ_ANLEGER          0.041370
CAMEO_DEU_2015_8B       0.041306
GEBAEUDETYP_8.0         0.041007
ZABEOTYP_6.0            0.038268
CAMEO_WEALTH_4.0        0.037652
SHOPPER_TYP_2.0         0.036673
                          ...   
SEMIO_ERL              -0.042593
CAMEO_DEU_2015_2C      -0.043125
CAMEO_DEU_2015_4A      -0.043914
MIN_GEBAEUDEJAHR       -0.044092
CAMEO_DEU_2015_4C      -0.044538
CAMEO_DEUG_2015_1.0    -0.045779
OST_WEST_KZ_W          -0.045997
CAMEO_DEU_2015_2D      -0.047267
FINANZTYP_3.0          -0.047413
SEMIO_LUST             -0.048255
WOHNDAUER_2008         -0.050241
ZABEOTYP_2.0           -0.050254
CAMEO_LIFESTAGE_3.0    -0.050804
LP_FAMILIE_FEIN_11.0   -0.051012
NATIONALITAET_KZ_1.0   -0.051345
LP_FAMILIE_FEIN_10.0   -0.051996
WOHNLAGE               -0.053640
KBA13_ANZAHL_PKW       -0.059370
ONLINE_AFFINITAET      -0.059775
CAMEO_LIFESTAGE_4.0    -0.060243
CAMEO_DEUG_2015_3.0    -0.061689
FINANZTYP_2.0          -0.067651
FINANZ_VORSORGER       -0.070182
CAMEO_DEUG_2015_4.0    -0.070865
ALTERSKATEGORIE_GROB   -0.072071
LP_FAMILIE_GROB_5.0    -0.075726
GEBAEUDETYP_1.0        -0.081830
CAMEO_DEUG_2015_2.0    -0.084560
BALLRAUM               -0.087028
GEBAEUDETYP_RASTER     -0.090855
ANZ_PERSONEN           -0.092381
ZABEOTYP_1.0           -0.093843
LP_STATUS_FEIN_9.0     -0.096223
LP_STATUS_GROB_4.0     -0.097729
CAMEO_WEALTH_1.0       -0.099121
CAMEO_WEALTH_2.0       -0.100867
MOVEMENT_AVANTGARDE    -0.109869
GREEN_AVANTGARDE_1.0   -0.109869
LP_STATUS_FEIN_10.0    -0.114886
LP_STATUS_GROB_5.0     -0.114886
INNENSTADT             -0.117615
LP_LEBENSPHASE_GROB    -0.125822
KONSUMNAEHE            -0.126616
PLZ8_GBZ               -0.127870
LP_LEBENSPHASE_FEIN    -0.139584
KBA05_GBZ              -0.170973
PLZ8_ANTG1             -0.173776
FINANZ_MINIMALIST      -0.174078
KBA05_ANTG1            -0.179077
MOBI_REGIO             -0.194190
Name: 0, Length: 216, dtype: float64
In [57]:
# Map weights for the second principal component to corresponding feature names
# and then print the linked values, sorted by weight.
pca_wgt_1 = pca_weight(pca_85, azdias_scaled, 1)
print(pca_wgt_1)
ALTERSKATEGORIE_GROB     0.231065
FINANZ_VORSORGER         0.214624
ZABEOTYP_3.0             0.194211
SEMIO_ERL                0.179393
SEMIO_LUST               0.164313
RETOURTYP_BK_S           0.153375
W_KEIT_KIND_HH           0.123573
DECADE_60s               0.110940
CJT_GESAMTTYP_2.0        0.105913
DECADE_50s               0.102949
FINANZ_MINIMALIST        0.095445
FINANZTYP_2.0            0.094562
FINANZTYP_5.0            0.091111
LP_STATUS_FEIN_1.0       0.080734
FINANZ_HAUSBAUER         0.076754
SEMIO_KRIT               0.071891
NATIONALITAET_KZ_1.0     0.068755
CJT_GESAMTTYP_1.0        0.068360
DECADE_40s               0.067847
SHOPPER_TYP_3.0          0.067745
FINANZTYP_6.0            0.064956
DECADE_70s               0.058516
LP_FAMILIE_FEIN_1.0      0.058040
LP_FAMILIE_GROB_1.0      0.058040
GFK_URLAUBERTYP_4.0      0.054983
WOHNDAUER_2008           0.054773
SEMIO_KAEM               0.052859
EWDICHTE                 0.050167
ORTSGR_KLS9              0.049229
PLZ8_ANTG3               0.048390
LP_STATUS_FEIN_3.0       0.047261
PLZ8_ANTG4               0.045279
PLZ8_BAUMAX              0.044513
GFK_URLAUBERTYP_7.0      0.043657
CAMEO_LIFESTAGE_5.0      0.043517
KBA05_ANTG4              0.040793
ARBEIT                   0.039882
LP_FAMILIE_GROB_2.0      0.039450
LP_FAMILIE_FEIN_2.0      0.039450
ANREDE_KZ_2.0            0.038775
ANZ_HAUSHALTE_AKTIV      0.037490
RELAT_AB                 0.036486
CAMEO_DEU_2015_9E        0.035830
CAMEO_WEALTH_5.0         0.035068
PLZ8_ANTG2               0.034580
CAMEO_DEU_2015_8D        0.032519
GFK_URLAUBERTYP_3.0      0.031308
CAMEO_DEUG_2015_8.0      0.031204
SEMIO_DOM                0.027200
HH_EINKOMMEN_SCORE       0.025429
                           ...   
KBA05_ANTG1             -0.036716
PLZ8_GBZ                -0.037068
CJT_GESAMTTYP_3.0       -0.037162
MIN_GEBAEUDEJAHR        -0.037895
LP_FAMILIE_FEIN_8.0     -0.038092
KONSUMNAEHE             -0.038732
ANREDE_KZ_1.0           -0.038775
INNENSTADT              -0.039226
GFK_URLAUBERTYP_12.0    -0.039640
LP_FAMILIE_FEIN_7.0     -0.040836
LP_LEBENSPHASE_FEIN     -0.040936
GFK_URLAUBERTYP_2.0     -0.042408
CJT_GESAMTTYP_6.0       -0.043274
KBA05_GBZ               -0.045073
MOBI_REGIO              -0.045524
LP_FAMILIE_GROB_3.0     -0.045934
LP_FAMILIE_GROB_5.0     -0.046156
NATIONALITAET_KZ_2.0    -0.047087
SHOPPER_TYP_0.0         -0.047572
PLZ8_ANTG1              -0.047691
NATIONALITAET_KZ_3.0    -0.048632
LP_LEBENSPHASE_GROB     -0.048852
DECADE_80s              -0.050648
HEALTH_TYP              -0.050795
ZABEOTYP_1.0            -0.050921
CJT_GESAMTTYP_4.0       -0.054688
SEMIO_SOZ               -0.064676
ANZ_PERSONEN            -0.064744
LP_FAMILIE_GROB_4.0     -0.066929
FINANZTYP_3.0           -0.069196
GFK_URLAUBERTYP_9.0     -0.071016
LP_STATUS_FEIN_5.0      -0.076719
FINANZTYP_4.0           -0.084824
ZABEOTYP_5.0            -0.095955
LP_STATUS_FEIN_2.0      -0.098708
ZABEOTYP_4.0            -0.102752
SEMIO_MAT               -0.125481
SEMIO_FAM               -0.131205
FINANZTYP_1.0           -0.133975
ONLINE_AFFINITAET       -0.156328
SEMIO_KULT              -0.160297
SEMIO_RAT               -0.165317
ALTER_HH                -0.179303
FINANZ_ANLEGER          -0.199105
DECADE_90s              -0.200596
SEMIO_PFLICHT           -0.201908
SEMIO_TRADV             -0.204095
FINANZ_UNAUFFAELLIGER   -0.209761
SEMIO_REL               -0.212974
FINANZ_SPARER           -0.227505
Name: 1, Length: 216, dtype: float64
In [58]:
# Map weights for the third principal component to corresponding feature names
# and then print the linked values, sorted by weight.
pca_wgt_2 = pca_weight(pca_85, azdias_scaled, 2)
print(pca_wgt_2)
ANREDE_KZ_1.0            0.312271
SEMIO_VERT               0.287604
SEMIO_FAM                0.236336
SEMIO_SOZ                0.230526
SEMIO_KULT               0.228507
FINANZTYP_5.0            0.129251
FINANZ_MINIMALIST        0.113591
SEMIO_REL                0.111111
ZABEOTYP_1.0             0.109823
GREEN_AVANTGARDE_1.0     0.109483
MOVEMENT_AVANTGARDE      0.109483
SHOPPER_TYP_0.0          0.102083
ORTSGR_KLS9              0.082681
EWDICHTE                 0.082531
SEMIO_MAT                0.081125
LP_STATUS_FEIN_10.0      0.077531
LP_STATUS_GROB_5.0       0.077531
RETOURTYP_BK_S           0.073104
PLZ8_ANTG3               0.056061
PLZ8_BAUMAX              0.055983
W_KEIT_KIND_HH           0.055873
PLZ8_ANTG4               0.054730
LP_STATUS_FEIN_3.0       0.049803
SHOPPER_TYP_1.0          0.046983
PLZ8_ANTG2               0.043178
ZABEOTYP_6.0             0.042737
RELAT_AB                 0.042643
FINANZ_VORSORGER         0.039344
ARBEIT                   0.038664
LP_STATUS_FEIN_1.0       0.032894
LP_STATUS_GROB_3.0       0.032742
CAMEO_LIFESTAGE_1.0      0.031625
GEBAEUDETYP_3.0          0.031623
SEMIO_LUST               0.031609
CAMEO_DEUG_2015_1.0      0.029461
CAMEO_WEALTH_1.0         0.027426
LP_STATUS_FEIN_7.0       0.026452
NATIONALITAET_KZ_2.0     0.026116
CAMEO_DEU_2015_9C        0.024817
KBA05_ANTG4              0.024505
GFK_URLAUBERTYP_4.0      0.024489
DECADE_50s               0.024037
CAMEO_DEUG_2015_9.0      0.023685
PLZ8_HHZ                 0.023459
LP_FAMILIE_GROB_2.0      0.023379
LP_FAMILIE_FEIN_2.0      0.023379
DECADE_60s               0.023119
LP_STATUS_FEIN_6.0       0.022260
ANZ_HAUSHALTE_AKTIV      0.021869
CAMEO_WEALTH_5.0         0.021444
                           ...   
CAMEO_LIFESTAGE_3.0     -0.022003
LP_FAMILIE_FEIN_3.0     -0.023534
MOBI_REGIO              -0.023991
CAMEO_LIFESTAGE_2.0     -0.024035
LP_FAMILIE_FEIN_5.0     -0.024287
ZABEOTYP_5.0            -0.026050
GFK_URLAUBERTYP_9.0     -0.026217
FINANZTYP_2.0           -0.026478
NATIONALITAET_KZ_3.0    -0.026749
CAMEO_DEU_2015_4A       -0.027316
GEBAEUDETYP_1.0         -0.028757
LP_STATUS_GROB_2.0      -0.028805
CJT_GESAMTTYP_2.0       -0.031233
FINANZ_UNAUFFAELLIGER   -0.031664
PLZ8_GBZ                -0.031725
ALTER_HH                -0.032148
REGIOTYP                -0.033724
LP_FAMILIE_FEIN_4.0     -0.034268
CAMEO_DEUG_2015_4.0     -0.035489
ZABEOTYP_3.0            -0.035883
LP_STATUS_FEIN_9.0      -0.036013
LP_STATUS_GROB_4.0      -0.037163
DECADE_90s              -0.039170
CAMEO_WEALTH_2.0        -0.043627
FINANZ_SPARER           -0.043683
GEBAEUDETYP_RASTER      -0.043777
LP_FAMILIE_GROB_3.0     -0.047990
PLZ8_ANTG1              -0.049030
HH_EINKOMMEN_SCORE      -0.049229
SHOPPER_TYP_3.0         -0.051407
FINANZ_HAUSBAUER        -0.052458
KKK                     -0.053326
KONSUMNAEHE             -0.056934
ZABEOTYP_4.0            -0.057847
WOHNLAGE                -0.061560
BALLRAUM                -0.063748
LP_STATUS_FEIN_2.0      -0.067311
INNENSTADT              -0.069794
LP_STATUS_FEIN_4.0      -0.078767
FINANZTYP_1.0           -0.082144
SHOPPER_TYP_2.0         -0.085362
MOVEMENT_MAINSTREAM     -0.106297
GREEN_AVANTGARDE_0.0    -0.109483
SEMIO_RAT               -0.137368
FINANZ_ANLEGER          -0.145167
SEMIO_ERL               -0.188257
SEMIO_KRIT              -0.239714
SEMIO_DOM               -0.246844
SEMIO_KAEM              -0.279715
ANREDE_KZ_2.0           -0.312271
Name: 2, Length: 216, dtype: float64

Discussion 2.3: Interpret Principal Components

Principal Component 0:

  • Two of the strongest positive feature weights for this component are LP_STATUS_GROB_1.0 (single low-income and average earners of younger age) and CAMEO_WEALTH_5.0 (Poorer Households) as well as several PLZ8* household macrocell features. That implies that this component consists of lower-income households and the cluster is comprised of neighborhoods with certain types of households. The strongest negative feature weights are MOBI_REGIO and KBA05_ANTG1 which add additional neighborhood and mobility aspects to this cluster.

Principal Component 1:

  • Two strongest feature weights for this component are ALTERSKATEGORIE_GROB (older estimated age) and FINANZ_VORSORGER (lower financial preparedness) which implies the individuals in this cluster are older and less financially well-off. The strongest negative feature weights are SEMIO_REL and FINANZ_SPARER which indicate this cluster also has something to do with religious affinity and money saving.

Principal Component 2:

  • The strongest feature weights in this component are ANREDE_KZ_1.0 (male), SEMIO_VERT (dreamful personality), SEMIO_FAM (family-minded) and SEMIO_SOZ (socially-minded). That implies this cluster has something to do with male gender and personality attitudes. The strongest negative weights are ANREDE_KZ_2.0 (female), SEMIO_DOM (dominant-minded) and SEMIO_KAEM (combative attitude) which further reinforce the gender and personality aspects of this cluster.

Step 3: Clustering

Step 3.1: Apply Clustering to General Population

You've assessed and cleaned the demographics data, then scaled and transformed them. Now, it's time to see how the data clusters in the principal components space. In this substep, you will apply k-means clustering to the dataset and use the average within-cluster distances from each point to their assigned cluster's centroid to decide on a number of clusters to keep.

  • Use sklearn's KMeans class to perform k-means clustering on the PCA-transformed data.
  • Then, compute the average difference from each point to its assigned cluster's center. Hint: The KMeans object's .score() method might be useful here, but note that in sklearn, scores tend to be defined so that larger is better. Try applying it to a small, toy dataset, or use an internet search to help your understanding.
  • Perform the above two steps for a number of different cluster counts. You can then see how the average distance decreases with an increasing number of clusters. However, each additional cluster provides a smaller net benefit. Use this fact to select a final number of clusters in which to group the data. Warning: because of the large size of the dataset, it can take a long time for the algorithm to resolve. The more clusters to fit, the longer the algorithm will take. You should test for cluster counts through at least 10 clusters to get the full picture, but you shouldn't need to test for a number of clusters above about 30.
  • Once you've selected a final number of clusters to use, re-fit a KMeans instance to perform the clustering operation. Make sure that you also obtain the cluster assignments for the general demographics data, since you'll be using them in the final Step 3.3.
In [59]:
def plot_data(data, labels):
    '''
    Plot data with colors associated with labels
    '''
    fig = plt.figure();
    ax = Axes3D(fig)
    ax.scatter(data[:, 0], data[:, 1], data[:, 2], c=labels, cmap='tab10');
In [60]:
# Over a number of different cluster counts...
kmeans = KMeans(n_clusters=3)

# run k-means clustering on the data and...
model = kmeans.fit(azdias_pca)    
azdias_predict = model.predict(azdias_pca)
plot_data(azdias_pca, azdias_predict)

# compute the average within-cluster distances.
    
    
In [61]:
# Investigate the change in within-cluster distance across number of clusters.
# HINT: Use matplotlib's plot function to visualize this relationship.

# Borrowed from the practice project helper functions
def get_kmeans_score(data, center):
    '''
    returns the kmeans score regarding SSE for points to centers
    INPUT:
        data - the dataset you want to fit kmeans to
        center - the number of centers you want (the k value)
    OUTPUT:
        score - the SSE score for the kmeans model fit to the data
    '''
    #instantiate kmeans
    kmeans = KMeans(n_clusters=center)

    # Then fit the model to your data using the fit method
    model = kmeans.fit(data)
    
    # Obtain a score related to the model fit
    score = np.abs(model.score(data))
    
    return score

scores = []
centers = list(range(1,21))

for center in centers:
    scores.append(get_kmeans_score(azdias_pca, center))
In [62]:
plt.plot(centers, scores, linestyle='--', marker='o')
plt.xlabel('K')
plt.xticks(centers)
plt.ylabel('SSE')
plt.title('SSE vs. K')
plt.show()
In [93]:
# Re-fit the k-means model with the selected number of clusters and obtain
# cluster predictions for the general population demographics data.

kmeans = KMeans(n_clusters=11)

# run k-means clustering on the data and...
model = kmeans.fit(azdias_pca)    
azdias_predict = model.predict(azdias_pca)
plot_data(azdias_pca, azdias_predict)

Discussion 3.1: Apply Clustering to General Population

The elbow of the scree plot is at approximately 11 so I selected that as the number of clusters in my k-means model. We can see a neat 3D visual representation of some of those clusters above. I saw some, because obviously several clusters will be hidden from any direction in a 3D view.

Step 3.2: Apply All Steps to the Customer Data

Now that you have clusters and cluster centers for the general population, it's time to see how the customer data maps on to those clusters. Take care to not confuse this for re-fitting all of the models to the customer data. Instead, you're going to use the fits from the general population to clean, transform, and cluster the customer data. In the last step of the project, you will interpret how the general population fits apply to the customer data.

  • Don't forget when loading in the customers data, that it is semicolon (;) delimited.
  • Apply the same feature wrangling, selection, and engineering steps to the customer demographics using the clean_data() function you created earlier. (You can assume that the customer demographics data has similar meaning behind missing data patterns as the general demographics data.)
  • Use the sklearn objects from the general demographics data, and apply their transformations to the customers data. That is, you should not be using a .fit() or .fit_transform() method to re-fit the old objects, nor should you be creating new sklearn objects! Carry the data through the feature scaling, PCA, and clustering steps, obtaining cluster assignments for all of the data in the customer demographics data.
In [94]:
# Load in the customer demographics data.
customers = pd.read_csv('Udacity_CUSTOMERS_Subset.csv', sep=';')
In [95]:
# Clean the data
customers_cleaned = clean_data(customers, feat_info)
/anaconda3/lib/python3.7/site-packages/ipykernel_launcher.py:61: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
In [96]:
customers_cleaned.shape
Out[96]:
(142538, 215)
In [97]:
# We're missing one column, figure out what it is
set(azdias_scaled.columns).difference(customers_cleaned.columns)
Out[97]:
{'GEBAEUDETYP_5.0'}
In [98]:
# It's a one-hot encoded column that's missing, so we can safely set it to 0
customers_cleaned['GEBAEUDETYP_5.0'] = 0
In [99]:
# Replace missing values with median

customers_cleaned[[
    'ALTER_HH', 'KKK', 'REGIOTYP', 'W_KEIT_KIND_HH', 'KBA05_ANTG2',
    'KBA05_ANTG3', 'KBA05_ANTG4', 'KBA05_GBZ', 'MOBI_REGIO', 'KBA05_ANTG1',
    'PLZ8_BAUMAX', 'PLZ8_ANTG2', 'PLZ8_HHZ', 'PLZ8_GBZ', 'PLZ8_ANTG4',
    'PLZ8_ANTG3', 'PLZ8_ANTG1', 'KBA13_ANZAHL_PKW', 'LP_LEBENSPHASE_FEIN',
    'LP_LEBENSPHASE_GROB', 'ANZ_HAUSHALTE_AKTIV', 'RELAT_AB', 'ARBEIT',
    'ORTSGR_KLS9', 'ANZ_HH_TITEL', 'EWDICHTE', 'BALLRAUM', 'INNENSTADT',
    'GEBAEUDETYP_RASTER', 'WOHNLAGE', 'MIN_GEBAEUDEJAHR', 'HH_EINKOMMEN_SCORE',
    'RETOURTYP_BK_S', 'ONLINE_AFFINITAET', 'KONSUMNAEHE'
]] = impute.fit_transform(customers_cleaned[[
    'ALTER_HH', 'KKK', 'REGIOTYP', 'W_KEIT_KIND_HH', 'KBA05_ANTG2',
    'KBA05_ANTG3', 'KBA05_ANTG4', 'KBA05_GBZ', 'MOBI_REGIO', 'KBA05_ANTG1',
    'PLZ8_BAUMAX', 'PLZ8_ANTG2', 'PLZ8_HHZ', 'PLZ8_GBZ', 'PLZ8_ANTG4',
    'PLZ8_ANTG3', 'PLZ8_ANTG1', 'KBA13_ANZAHL_PKW', 'LP_LEBENSPHASE_FEIN',
    'LP_LEBENSPHASE_GROB', 'ANZ_HAUSHALTE_AKTIV', 'RELAT_AB', 'ARBEIT',
    'ORTSGR_KLS9', 'ANZ_HH_TITEL', 'EWDICHTE', 'BALLRAUM', 'INNENSTADT',
    'GEBAEUDETYP_RASTER', 'WOHNLAGE', 'MIN_GEBAEUDEJAHR', 'HH_EINKOMMEN_SCORE',
    'RETOURTYP_BK_S', 'ONLINE_AFFINITAET', 'KONSUMNAEHE'
]])
In [100]:
customers_scaled = pd.DataFrame(scaler.fit_transform(customers_cleaned))
In [101]:
customers_scaled.columns = customers_cleaned.columns
customers_scaled.index = customers_cleaned.index
customers_scaled = pd.DataFrame(customers_scaled, columns=list(customers_cleaned))
In [102]:
# Re-fit the k-means model with the selected number of clusters and obtain
# cluster predictions for the general population demographics data.

# run k-means clustering on the data and...
customers_pca = pca_85.transform(customers_scaled)
customers_predict = model.predict(customers_pca)
plot_data(customers_pca, customers_predict)

Step 3.3: Compare Customer Data to Demographics Data

At this point, you have clustered data based on demographics of the general population of Germany, and seen how the customer data for a mail-order sales company maps onto those demographic clusters. In this final substep, you will compare the two cluster distributions to see where the strongest customer base for the company is.

Consider the proportion of persons in each cluster for the general population, and the proportions for the customers. If we think the company's customer base to be universal, then the cluster assignment proportions should be fairly similar between the two. If there are only particular segments of the population that are interested in the company's products, then we should see a mismatch from one to the other. If there is a higher proportion of persons in a cluster for the customer data compared to the general population (e.g. 5% of persons are assigned to a cluster for the general population, but 15% of the customer data is closest to that cluster's centroid) then that suggests the people in that cluster to be a target audience for the company. On the other hand, the proportion of the data in a cluster being larger in the general population than the customer data (e.g. only 2% of customers closest to a population centroid that captures 6% of the data) suggests that group of persons to be outside of the target demographics.

Take a look at the following points in this step:

  • Compute the proportion of data points in each cluster for the general population and the customer data. Visualizations will be useful here: both for the individual dataset proportions, but also to visualize the ratios in cluster representation between groups. Seaborn's countplot() or barplot() function could be handy.
    • Recall the analysis you performed in step 1.1.3 of the project, where you separated out certain data points from the dataset if they had more than a specified threshold of missing values. If you found that this group was qualitatively different from the main bulk of the data, you should treat this as an additional data cluster in this analysis. Make sure that you account for the number of data points in this subset, for both the general population and customer datasets, when making your computations!
  • Which cluster or clusters are overrepresented in the customer dataset compared to the general population? Select at least one such cluster and infer what kind of people might be represented by that cluster. Use the principal component interpretations from step 2.3 or look at additional components to help you make this inference. Alternatively, you can use the .inverse_transform() method of the PCA and StandardScaler objects to transform centroids back to the original data space and interpret the retrieved values directly.
  • Perform a similar investigation for the underrepresented clusters. Which cluster or clusters are underrepresented in the customer dataset compared to the general population, and what kinds of people are typified by these clusters?
In [103]:
# Compare the proportion of data in each cluster for the customer data to the
# proportion of data in each cluster for the general population.

figure, axs = plt.subplots(nrows=1, ncols=2)
figure.subplots_adjust(hspace=1, wspace=.3)

sns.countplot(customers_predict, ax=axs[0])
axs[0].set_title('Customer Clusters')
sns.countplot(azdias_predict, ax=axs[1])
axs[1].set_title('General Clusters')
Out[103]:
Text(0.5, 1.0, 'General Clusters')
In [107]:
# What kinds of people are part of a cluster that is overrepresented in the
# customer data compared to the general population?

# Cluster 6 is overrepresented

centroid_6 = scaler.inverse_transform(pca_85.inverse_transform(model.cluster_centers_[6]))
overrepresented_6 = pd.Series(data = centroid_6, index = customers_scaled.columns)
In [108]:
pca_wgt_6 = pca_weight(pca_85, customers_scaled, 6)
print(pca_wgt_6)
ANREDE_KZ_2.0            0.299237
SEMIO_REL                0.249958
SEMIO_MAT                0.190864
CAMEO_DEU_2015_4A        0.189652
CJT_GESAMTTYP_1.0        0.182585
MIN_GEBAEUDEJAHR         0.157762
ANZ_HH_TITEL             0.152221
SEMIO_FAM                0.140093
KBA05_GBZ                0.135886
CAMEO_DEUG_2015_9.0      0.130220
WOHNDAUER_2008           0.123608
CAMEO_DEUG_2015_1.0      0.116139
DECADE_80s               0.101635
LP_FAMILIE_FEIN_5.0      0.093120
GFK_URLAUBERTYP_9.0      0.092317
NATIONALITAET_KZ_2.0     0.091366
CAMEO_DEU_2015_5C        0.084602
KBA05_ANTG3              0.079902
KBA05_ANTG2              0.077029
WOHNLAGE                 0.074980
CAMEO_DEU_2015_5B        0.073325
CAMEO_DEU_2015_1A        0.073190
ANZ_HAUSHALTE_AKTIV      0.070594
MOVEMENT_MAINSTREAM      0.070389
CAMEO_DEUG_2015_4.0      0.069232
LP_STATUS_GROB_3.0       0.065661
CAMEO_DEU_2015_4C        0.060050
GFK_URLAUBERTYP_5.0      0.054350
CAMEO_DEUG_2015_2.0      0.052704
GEBAEUDETYP_3.0          0.051147
LP_FAMILIE_FEIN_2.0      0.051032
BALLRAUM                 0.049822
GFK_URLAUBERTYP_12.0     0.049553
LP_FAMILIE_GROB_1.0      0.048302
KBA05_ANTG1              0.048212
EWDICHTE                 0.045815
LP_FAMILIE_FEIN_1.0      0.045219
LP_STATUS_FEIN_10.0      0.045054
KBA05_ANTG4              0.044640
KONSUMNAEHE              0.044337
FINANZ_UNAUFFAELLIGER    0.041071
FINANZ_HAUSBAUER         0.039455
CAMEO_WEALTH_2.0         0.038300
SHOPPER_TYP_3.0          0.034257
SHOPPER_TYP_2.0          0.031974
GEBAEUDETYP_6.0          0.030956
CAMEO_DEUG_2015_3.0      0.028821
GEBAEUDETYP_4.0          0.027809
LP_STATUS_FEIN_5.0       0.026064
CAMEO_DEUG_2015_5.0      0.025000
                           ...   
ZABEOTYP_6.0            -0.029703
SOHO_KZ_0.0             -0.029703
LP_STATUS_GROB_2.0      -0.030158
LP_FAMILIE_GROB_4.0     -0.030690
CAMEO_DEUG_2015_6.0     -0.030869
ARBEIT                  -0.031052
CAMEO_DEUG_2015_8.0     -0.031628
GFK_URLAUBERTYP_7.0     -0.033196
NATIONALITAET_KZ_1.0    -0.033648
ONLINE_AFFINITAET       -0.033726
DECADE_70s              -0.035811
KBA13_ANZAHL_PKW        -0.036520
OST_WEST_KZ_W           -0.036619
CAMEO_DEU_2015_5D       -0.037209
SEMIO_DOM               -0.037907
SEMIO_KRIT              -0.038216
CAMEO_WEALTH_1.0        -0.038300
SEMIO_ERL               -0.038853
CAMEO_DEU_2015_1E       -0.040202
SEMIO_PFLICHT           -0.043190
RELAT_AB                -0.045907
CJT_GESAMTTYP_3.0       -0.049003
GFK_URLAUBERTYP_11.0    -0.050938
GREEN_AVANTGARDE_0.0    -0.053152
CAMEO_LIFESTAGE_2.0     -0.054023
CAMEO_DEU_2015_1D       -0.055169
OST_WEST_KZ_O           -0.058406
CAMEO_DEU_2015_1C       -0.058406
NATIONALITAET_KZ_3.0    -0.059116
SHOPPER_TYP_0.0         -0.061741
CAMEO_DEUG_2015_7.0     -0.075507
SEMIO_VERT              -0.077539
LP_FAMILIE_FEIN_10.0    -0.078046
LP_FAMILIE_FEIN_3.0     -0.082791
CAMEO_DEU_2015_1B       -0.083686
GEBAEUDETYP_RASTER      -0.084454
SEMIO_RAT               -0.085288
SEMIO_KAEM              -0.085877
SEMIO_TRADV             -0.088093
CJT_GESAMTTYP_2.0       -0.092546
LP_LEBENSPHASE_FEIN     -0.100159
DECADE_90s              -0.108986
GFK_URLAUBERTYP_10.0    -0.114475
ANZ_PERSONEN            -0.136425
RETOURTYP_BK_S          -0.140381
ANZ_TITEL               -0.144952
ALTER_HH                -0.152945
CAMEO_DEU_2015_3D       -0.189019
SEMIO_SOZ               -0.271844
ANREDE_KZ_1.0           -0.314703
Name: 6, Length: 216, dtype: float64
In [110]:
cluster_specs = pd.DataFrame(scaler.inverse_transform(pca_85.inverse_transform(
    model.cluster_centers_)), columns=customers_cleaned.columns)
cluster_6 = cluster_specs.iloc[6]
pd.DataFrame(dict(cluster_6=cluster_6, pca_wgt_6=pca_wgt_6)
             ).reset_index().sort_values(by='pca_wgt_6', ascending=False)
Out[110]:
index cluster_6 pca_wgt_6
3 ANREDE_KZ_2.0 0.414051 0.299237
195 SEMIO_REL 3.293012 0.249958
192 SEMIO_MAT 3.557407 0.190864
32 CAMEO_DEU_2015_4A 0.026178 0.189652
73 CJT_GESAMTTYP_1.0 0.168147 0.182585
164 MIN_GEBAEUDEJAHR 1993.271066 0.157762
5 ANZ_HH_TITEL 0.083259 0.152221
187 SEMIO_FAM 4.128801 0.140093
127 KBA05_GBZ 3.600844 0.135886
18 CAMEO_DEUG_2015_9.0 0.347324 0.130220
207 WOHNDAUER_2008 8.785108 0.123608
10 CAMEO_DEUG_2015_1.0 0.331016 0.116139
83 DECADE_80s 0.072101 0.101635
137 LP_FAMILIE_FEIN_5.0 -0.001881 0.093120
117 GFK_URLAUBERTYP_9.0 0.030393 0.092317
169 NATIONALITAET_KZ_2.0 0.054346 0.091366
39 CAMEO_DEU_2015_5C 0.009632 0.084602
125 KBA05_ANTG3 0.310328 0.079902
124 KBA05_ANTG2 1.243131 0.077029
208 WOHNLAGE 3.929960 0.074980
38 CAMEO_DEU_2015_5B 0.052659 0.073325
19 CAMEO_DEU_2015_1A -0.006453 0.073190
4 ANZ_HAUSHALTE_AKTIV 6.664792 0.070594
167 MOVEMENT_MAINSTREAM 0.557268 0.070389
13 CAMEO_DEUG_2015_4.0 0.090431 0.069232
161 LP_STATUS_GROB_3.0 0.232662 0.065661
34 CAMEO_DEU_2015_4C 0.022616 0.060050
113 GFK_URLAUBERTYP_5.0 0.028722 0.054350
11 CAMEO_DEUG_2015_2.0 0.723493 0.052704
100 GEBAEUDETYP_3.0 0.076846 0.051147
134 LP_FAMILIE_FEIN_2.0 0.430925 0.051032
9 BALLRAUM 4.293779 0.049822
109 GFK_URLAUBERTYP_12.0 0.162335 0.049553
142 LP_FAMILIE_GROB_1.0 0.283940 0.048302
123 KBA05_ANTG1 2.210892 0.048212
85 EWDICHTE 3.836834 0.045815
131 LP_FAMILIE_FEIN_1.0 0.006494 0.045219
150 LP_STATUS_FEIN_10.0 0.542383 0.045054
126 KBA05_ANTG4 0.165533 0.044640
130 KONSUMNAEHE 3.133769 0.044337
96 FINANZ_UNAUFFAELLIGER 1.840892 0.041071
93 FINANZ_HAUSBAUER 2.300658 0.039455
69 CAMEO_WEALTH_2.0 0.267000 0.038300
202 SHOPPER_TYP_3.0 0.256186 0.034257
201 SHOPPER_TYP_2.0 0.119232 0.031974
103 GEBAEUDETYP_6.0 -0.009896 0.030956
12 CAMEO_DEUG_2015_3.0 0.085190 0.028821
101 GEBAEUDETYP_4.0 -0.010094 0.027809
154 LP_STATUS_FEIN_5.0 0.009357 0.026064
14 CAMEO_DEUG_2015_5.0 0.047890 0.025000
... ... ... ...
203 SOHO_KZ_0.0 0.993730 -0.029703
215 ZABEOTYP_6.0 0.046134 -0.029703
160 LP_STATUS_GROB_2.0 0.129185 -0.030158
145 LP_FAMILIE_GROB_4.0 0.020972 -0.030690
15 CAMEO_DEUG_2015_6.0 0.079600 -0.030869
8 ARBEIT 2.788760 -0.031052
17 CAMEO_DEUG_2015_8.0 -0.079208 -0.031628
115 GFK_URLAUBERTYP_7.0 0.004192 -0.033196
168 NATIONALITAET_KZ_1.0 0.990081 -0.033648
171 ONLINE_AFFINITAET 3.090029 -0.033726
82 DECADE_70s 0.079596 -0.035811
128 KBA13_ANZAHL_PKW 681.381828 -0.036520
174 OST_WEST_KZ_W 0.762551 -0.036619
40 CAMEO_DEU_2015_5D 0.023643 -0.037209
185 SEMIO_DOM 3.850017 -0.037907
189 SEMIO_KRIT 3.989564 -0.038216
68 CAMEO_WEALTH_1.0 0.291964 -0.038300
186 SEMIO_ERL 4.548491 -0.038853
23 CAMEO_DEU_2015_1E 0.036436 -0.040202
193 SEMIO_PFLICHT 2.987887 -0.043190
183 RELAT_AB 2.698851 -0.045907
75 CJT_GESAMTTYP_3.0 0.045989 -0.049003
108 GFK_URLAUBERTYP_11.0 0.011732 -0.050938
118 GREEN_AVANTGARDE_0.0 0.498882 -0.053152
64 CAMEO_LIFESTAGE_2.0 0.026618 -0.054023
22 CAMEO_DEU_2015_1D 0.013492 -0.055169
173 OST_WEST_KZ_O -0.003042 -0.058406
21 CAMEO_DEU_2015_1C -0.021953 -0.058406
170 NATIONALITAET_KZ_3.0 0.013710 -0.059116
199 SHOPPER_TYP_0.0 0.318197 -0.061741
16 CAMEO_DEUG_2015_7.0 -0.029193 -0.075507
198 SEMIO_VERT 5.716394 -0.077539
132 LP_FAMILIE_FEIN_10.0 0.315447 -0.078046
135 LP_FAMILIE_FEIN_3.0 0.001864 -0.082791
20 CAMEO_DEU_2015_1B -0.030296 -0.083686
105 GEBAEUDETYP_RASTER 4.043929 -0.084454
194 SEMIO_RAT 2.856052 -0.085288
188 SEMIO_KAEM 3.436896 -0.085877
197 SEMIO_TRADV 2.794050 -0.088093
74 CJT_GESAMTTYP_2.0 0.376435 -0.092546
147 LP_LEBENSPHASE_FEIN 20.445038 -0.100159
84 DECADE_90s 0.070969 -0.108986
107 GFK_URLAUBERTYP_10.0 0.271614 -0.114475
6 ANZ_PERSONEN 2.191173 -0.136425
184 RETOURTYP_BK_S 3.832056 -0.140381
7 ANZ_TITEL 0.017706 -0.144952
1 ALTER_HH 13.195225 -0.152945
31 CAMEO_DEU_2015_3D 0.076181 -0.189019
196 SEMIO_SOZ 4.171109 -0.271844
2 ANREDE_KZ_1.0 0.617697 -0.314703

216 rows × 3 columns

Overrepresented Cluster 6: Urban Upper- and Working-Class Thirty-something Women

This cluster is primarily urban working class and upper-class women in their 30s. They show a propensity for online ordering.

STRONGEST POSITIVE FEATURE WEIGHTS:

ANREDE_KZ_2.0            Female
SEMIO_REL                Religious: high affinity
SEMIO_MAT                Materialistic: average to high affinity
CAMEO_DEU_2015_4A        Family starter
CJT_GESAMTTYP_1.0        Advertising- and Consumptionminimalist
MIN_GEBAEUDEJAHR         First year building mentioned: 1993
SEMIO_FAM                Family-minded: average affinity
KBA05_GBZ                5-16 to 17-22 buildings in microcell
CAMEO_DEUG_2015_9.0      Urban working class
WOHNDAUER_2008           Length of residence 7-10 years
CAMEO_DEUG_2015_1.0      Upper class
DECADE_80s               Decade of youth: 1980s

STRONGEST NEGATIVE FEATURE WEIGHTS:

ALTER_HH                Birthdate head of household: 1955-01-01 to 1959-12-31
CAMEO_DEU_2015_3D       Secure Retirement
SEMIO_SOZ               Socially-minded: average affinity
ANREDE_KZ_1.0           Male

In [111]:
# What kinds of people are part of a cluster that is underrepresented in the
# customer data compared to the general population?

# Cluster 1 is underrepresented

centroid_1 = scaler.inverse_transform(pca_85.inverse_transform(model.cluster_centers_[1]))
underrepresented_c = pd.Series(data = centroid_1, index = customers_cleaned.columns)
In [112]:
pca_wgt_1 = pca_weight(pca_85, customers_scaled, 1)
print(pca_wgt_1)
ALTERSKATEGORIE_GROB    0.231065
LP_FAMILIE_FEIN_2.0     0.214624
CAMEO_LIFESTAGE_3.0     0.194211
CAMEO_DEU_2015_6B       0.179393
CAMEO_DEU_2015_7A       0.164313
CAMEO_DEU_2015_5F       0.153375
CAMEO_WEALTH_5.0        0.123573
FINANZTYP_6.0           0.110940
CJT_GESAMTTYP_5.0       0.105913
FINANZTYP_5.0           0.102949
GREEN_AVANTGARDE_0.0    0.095445
GFK_URLAUBERTYP_6.0     0.094562
GFK_URLAUBERTYP_9.0     0.091111
GEBAEUDETYP_8.0         0.080734
GFK_URLAUBERTYP_12.0    0.076754
CAMEO_DEU_2015_6E       0.071891
CAMEO_DEU_2015_2C       0.068755
CJT_GESAMTTYP_4.0       0.068360
FINANZTYP_4.0           0.067847
CAMEO_DEU_2015_9C       0.067745
GFK_URLAUBERTYP_10.0    0.064956
GFK_URLAUBERTYP_1.0     0.058516
SHOPPER_TYP_1.0         0.058040
ZABEOTYP_5.0            0.058040
LP_STATUS_FEIN_1.0      0.054983
CAMEO_WEALTH_3.0        0.054773
CAMEO_DEU_2015_6D       0.052859
GFK_URLAUBERTYP_4.0     0.050167
CAMEO_DEU_2015_3C       0.049229
CAMEO_DEU_2015_4D       0.048390
CAMEO_DEUG_2015_1.0     0.047261
CAMEO_DEU_2015_4E       0.045279
CAMEO_DEU_2015_5A       0.044513
LP_STATUS_FEIN_4.0      0.043657
MOVEMENT_AVANTGARDE     0.043517
LP_STATUS_GROB_5.0      0.040793
LP_LEBENSPHASE_FEIN     0.039882
ZABEOTYP_6.0            0.039450
SOHO_KZ_0.0             0.039450
FINANZ_VORSORGER        0.038775
FINANZ_ANLEGER          0.037490
CAMEO_DEU_2015_5E       0.036486
DECADE_60s              0.035830
CJT_GESAMTTYP_3.0       0.035068
CAMEO_DEU_2015_4C       0.034580
ARBEIT                  0.032519
LP_FAMILIE_GROB_5.0     0.031308
SEMIO_ERL               0.031204
CAMEO_DEU_2015_6A       0.027200
LP_STATUS_FEIN_10.0     0.025429
                          ...   
LP_STATUS_GROB_2.0     -0.036716
CAMEO_DEU_2015_5B      -0.037068
CJT_GESAMTTYP_6.0      -0.037162
CAMEO_DEU_2015_1D      -0.037895
ZABEOTYP_3.0           -0.038092
SHOPPER_TYP_0.0        -0.038732
FINANZ_SPARER          -0.038775
LP_STATUS_GROB_1.0     -0.039226
LP_FAMILIE_GROB_3.0    -0.039640
ZABEOTYP_2.0           -0.040836
GEBAEUDETYP_4.0        -0.040936
LP_FAMILIE_GROB_4.0    -0.042408
FINANZTYP_3.0          -0.043274
NATIONALITAET_KZ_1.0   -0.045073
CAMEO_DEU_2015_1E      -0.045524
GEBAEUDETYP_1.0        -0.045934
GEBAEUDETYP_3.0        -0.046156
CAMEO_DEU_2015_2D      -0.047087
CAMEO_DEU_2015_8D      -0.047572
CAMEO_DEU_2015_4B      -0.047691
CAMEO_DEU_2015_3A      -0.048632
GEBAEUDETYP_6.0        -0.048852
GFK_URLAUBERTYP_2.0    -0.050648
LP_STATUS_FEIN_9.0     -0.050795
CAMEO_LIFESTAGE_1.0    -0.050921
FINANZTYP_1.0          -0.054688
CAMEO_DEU_2015_8A      -0.064676
FINANZ_HAUSBAUER       -0.064744
GEBAEUDETYP_2.0        -0.066929
GFK_URLAUBERTYP_7.0    -0.069196
LP_STATUS_FEIN_6.0     -0.071016
CAMEO_DEUG_2015_3.0    -0.076719
GFK_URLAUBERTYP_8.0    -0.084824
CAMEO_LIFESTAGE_5.0    -0.095955
OST_WEST_KZ_W          -0.098708
CAMEO_LIFESTAGE_4.0    -0.102752
CAMEO_DEU_2015_7B      -0.125481
CAMEO_DEU_2015_6C      -0.131205
GFK_URLAUBERTYP_5.0    -0.133975
CAMEO_DEU_2015_3B      -0.156328
CAMEO_DEU_2015_6F      -0.160297
CAMEO_DEU_2015_7D      -0.165317
FINANZ_MINIMALIST      -0.179303
GFK_URLAUBERTYP_11.0   -0.199105
GFK_URLAUBERTYP_3.0    -0.200596
CAMEO_DEU_2015_7C      -0.201908
CAMEO_DEU_2015_8B      -0.204095
LP_FAMILIE_FEIN_1.0    -0.209761
CAMEO_DEU_2015_7E      -0.212974
GREEN_AVANTGARDE_1.0   -0.227505
Name: 1, Length: 216, dtype: float64
In [113]:
cluster_1 = cluster_specs.iloc[1]
pd.DataFrame(dict(cluster_1=cluster_1, pca_wgt_1=pca_wgt_1)
             ).reset_index().sort_values(by='pca_wgt_1', ascending=False)
Out[113]:
index cluster_1 pca_wgt_1
0 ALTERSKATEGORIE_GROB 2.738885 0.231065
134 LP_FAMILIE_FEIN_2.0 -0.186001 0.214624
65 CAMEO_LIFESTAGE_3.0 -0.076445 0.194211
44 CAMEO_DEU_2015_6B 0.020848 0.179393
49 CAMEO_DEU_2015_7A -0.093103 0.164313
42 CAMEO_DEU_2015_5F -0.058929 0.153375
72 CAMEO_WEALTH_5.0 0.089915 0.123573
91 FINANZTYP_6.0 0.107760 0.110940
77 CJT_GESAMTTYP_5.0 0.029476 0.105913
90 FINANZTYP_5.0 0.175772 0.102949
118 GREEN_AVANTGARDE_0.0 -0.203392 0.095445
114 GFK_URLAUBERTYP_6.0 -0.033287 0.094562
117 GFK_URLAUBERTYP_9.0 -0.038674 0.091111
104 GEBAEUDETYP_8.0 0.164161 0.080734
109 GFK_URLAUBERTYP_12.0 0.216361 0.076754
47 CAMEO_DEU_2015_6E 0.101887 0.071891
26 CAMEO_DEU_2015_2C -0.046919 0.068755
76 CJT_GESAMTTYP_4.0 0.082183 0.068360
89 FINANZTYP_4.0 -0.008582 0.067847
60 CAMEO_DEU_2015_9C -0.004306 0.067745
107 GFK_URLAUBERTYP_10.0 -0.007034 0.064956
106 GFK_URLAUBERTYP_1.0 -0.067050 0.058516
214 ZABEOTYP_5.0 0.025570 0.058040
200 SHOPPER_TYP_1.0 0.360782 0.058040
149 LP_STATUS_FEIN_1.0 0.073194 0.054983
70 CAMEO_WEALTH_3.0 -0.027477 0.054773
46 CAMEO_DEU_2015_6D 0.100640 0.052859
112 GFK_URLAUBERTYP_4.0 0.285481 0.050167
30 CAMEO_DEU_2015_3C 0.167304 0.049229
35 CAMEO_DEU_2015_4D 0.091356 0.048390
10 CAMEO_DEUG_2015_1.0 0.039257 0.047261
36 CAMEO_DEU_2015_4E 0.064631 0.045279
37 CAMEO_DEU_2015_5A 0.080826 0.044513
153 LP_STATUS_FEIN_4.0 -0.000028 0.043657
166 MOVEMENT_AVANTGARDE 0.406382 0.043517
163 LP_STATUS_GROB_5.0 0.548183 0.040793
147 LP_LEBENSPHASE_FEIN 29.074030 0.039882
203 SOHO_KZ_0.0 0.973523 0.039450
215 ZABEOTYP_6.0 0.006393 0.039450
97 FINANZ_VORSORGER 5.437041 0.038775
92 FINANZ_ANLEGER 1.938368 0.037490
41 CAMEO_DEU_2015_5E 0.034069 0.036486
81 DECADE_60s 0.210922 0.035830
75 CJT_GESAMTTYP_3.0 0.350912 0.035068
34 CAMEO_DEU_2015_4C 0.173486 0.034580
8 ARBEIT 2.856306 0.032519
146 LP_FAMILIE_GROB_5.0 0.349142 0.031308
186 SEMIO_ERL 5.409021 0.031204
43 CAMEO_DEU_2015_6A 0.072375 0.027200
150 LP_STATUS_FEIN_10.0 0.722306 0.025429
... ... ... ...
160 LP_STATUS_GROB_2.0 -0.092385 -0.036716
38 CAMEO_DEU_2015_5B -0.033238 -0.037068
78 CJT_GESAMTTYP_6.0 0.114975 -0.037162
22 CAMEO_DEU_2015_1D -0.004061 -0.037895
212 ZABEOTYP_3.0 0.402494 -0.038092
199 SHOPPER_TYP_0.0 0.014386 -0.038732
95 FINANZ_SPARER 0.578205 -0.038775
159 LP_STATUS_GROB_1.0 -0.013789 -0.039226
144 LP_FAMILIE_GROB_3.0 0.056082 -0.039640
211 ZABEOTYP_2.0 0.037548 -0.040836
101 GEBAEUDETYP_4.0 -0.018775 -0.040936
145 LP_FAMILIE_GROB_4.0 0.037973 -0.042408
88 FINANZTYP_3.0 0.098164 -0.043274
168 NATIONALITAET_KZ_1.0 0.872314 -0.045073
23 CAMEO_DEU_2015_1E -0.085881 -0.045524
98 GEBAEUDETYP_1.0 0.770854 -0.045934
100 GEBAEUDETYP_3.0 0.091370 -0.046156
27 CAMEO_DEU_2015_2D 0.139902 -0.047087
57 CAMEO_DEU_2015_8D -0.009926 -0.047572
33 CAMEO_DEU_2015_4B -0.059055 -0.047691
28 CAMEO_DEU_2015_3A 0.060590 -0.048632
103 GEBAEUDETYP_6.0 -0.011607 -0.048852
110 GFK_URLAUBERTYP_2.0 0.063083 -0.050648
158 LP_STATUS_FEIN_9.0 0.247563 -0.050795
63 CAMEO_LIFESTAGE_1.0 -0.004800 -0.050921
86 FINANZTYP_1.0 0.021870 -0.054688
54 CAMEO_DEU_2015_8A -0.051481 -0.064676
93 FINANZ_HAUSBAUER 2.366733 -0.064744
99 GEBAEUDETYP_2.0 0.008339 -0.066929
115 GFK_URLAUBERTYP_7.0 0.055623 -0.069196
155 LP_STATUS_FEIN_6.0 0.073648 -0.071016
12 CAMEO_DEUG_2015_3.0 0.064576 -0.076719
116 GFK_URLAUBERTYP_8.0 0.106761 -0.084824
67 CAMEO_LIFESTAGE_5.0 0.523290 -0.095955
174 OST_WEST_KZ_W 1.337565 -0.098708
66 CAMEO_LIFESTAGE_4.0 0.636585 -0.102752
50 CAMEO_DEU_2015_7B 0.088937 -0.125481
45 CAMEO_DEU_2015_6C -0.004775 -0.131205
113 GFK_URLAUBERTYP_5.0 0.525452 -0.133975
29 CAMEO_DEU_2015_3B 0.042318 -0.156328
48 CAMEO_DEU_2015_6F 0.001015 -0.160297
52 CAMEO_DEU_2015_7D 0.106283 -0.165317
94 FINANZ_MINIMALIST 4.814211 -0.179303
108 GFK_URLAUBERTYP_11.0 0.274089 -0.199105
111 GFK_URLAUBERTYP_3.0 0.390701 -0.200596
51 CAMEO_DEU_2015_7C 0.102015 -0.201908
55 CAMEO_DEU_2015_8B 0.204290 -0.204095
131 LP_FAMILIE_FEIN_1.0 0.647795 -0.209761
53 CAMEO_DEU_2015_7E 0.062291 -0.212974
119 GREEN_AVANTGARDE_1.0 1.076471 -0.227505

216 rows × 3 columns

Underrepresented Cluster 1: Older, Lower-income Singles and Families

This cluster seems to represent older households (singles and families).

STRONGEST POSITIVE FEATURE WEIGHTS:

ALTERSKATEGORIE_GROB    30 - 45 years old to 46 - 60 years old
LP_FAMILIE_FEIN_2.0     Single low-income earners of middle age
CAMEO_LIFESTAGE_3.0     Families With School Age Children
CAMEO_DEU_2015_6B       Petty Bourgeois
CAMEO_DEU_2015_7A       Journeymen
CAMEO_DEU_2015_5F       Active Retirement
CAMEO_WEALTH_5.0        Poorer Households
FINANZTYP_6.0           Inconspicuous
CJT_GESAMTTYP_5.0       Advertising- and Cross-Channel-Enthusiast
FINANZTYP_5.0           Investor

STRONGEST NEGATIVE FEATURE WEIGHTS:

CAMEO_DEU_2015_8B      Young & Mobile
LP_FAMILIE_FEIN_1.0    Single
CAMEO_DEU_2015_7E      Interested Retirees
GREEN_AVANTGARDE_1.0   Member of green avantgarde

Discussion 3.3: Compare Customer Data to Demographics Data

We can draw some conclusions about the types of customers that are more popular with the mail-order company: they're more likely to be women, urban, in their thirties, and higher income. Based on this analysis we can imagine some specific marketing and advertising campaigns directed at these target demographics!

In [ ]: